caroufredsel-rails/lib/assets/javascripts/caroufredsel.js.coffee

44 lines
927 B
CoffeeScript
Raw Permalink Normal View History

2012-10-07 18:44:41 +00:00
#= require jquery
#= require caroufredsel/jquery.mousewheel.min
#= require caroufredsel/jquery.touchSwipe.min
2012-12-14 19:46:46 +00:00
#= require caroufredsel/jquery.ba-throttle-debounce.min
#= require caroufredsel/jquery.carouFredSel-6.1.0
2012-10-07 18:44:41 +00:00
class @Carousel
2012-11-08 01:54:00 +00:00
constructor: (@carousel, options = {}) ->
2012-10-07 18:44:41 +00:00
if options.onChange
@onChange = options.onChange
delete options.onChange
options.scroll ||= {}
options.scroll.onBefore = (args) =>
@onChange($(args.items.new[0]))
@carousel.carouFredSel(options)
@onChange($(@carousel.children()[0]))
slideTo: (index, options = {}) =>
@carousel.trigger('slideTo', index, true, options)
this
moveTo: (index) =>
@slideTo(index, duration: 0)
this
pause: =>
@carousel.trigger('pause')
this
2012-11-10 14:45:51 +00:00
prev: =>
@carousel.trigger('prev')
next: =>
@carousel.trigger('next')
play: =>
@carousel.trigger('play')
2012-10-07 18:44:41 +00:00
onChange: (item) ->
null