Skip to content

Commit

Permalink
remove depecated callbacks, add arguments to events
Browse files Browse the repository at this point in the history
  • Loading branch information
il-matt-weber committed Jun 24, 2015
1 parent 9b345ac commit 9e9e18c
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions app/scripts/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ angular.module('slick', [])
infinite: "@"
initialSlide: "@"
lazyLoad: "@"
onBeforeChange: "&"
onAfterChange: "&"
onInit: "&"
onReInit: "&"
onSetPosition: "&"
onBeforeChange: "="
onAfterChange: "="
onInit: "="
onReInit: "="
onSetPosition: "="
pauseOnHover: "@"
pauseOnDotsHover: "@"
responsive: "="
Expand Down Expand Up @@ -88,9 +88,6 @@ angular.module('slick', [])
infinite: scope.infinite isnt "false"
initialSlide:scope.initialSlide or 0
lazyLoad: scope.lazyLoad or "ondemand"
beforeChange: if attrs.onBeforeChange then scope.onBeforeChange else undefined
onReInit: if attrs.onReInit then scope.onReInit else undefined
onSetPosition: if attrs.onSetPosition then scope.onSetPosition else undefined
pauseOnHover: scope.pauseOnHover isnt "false"
responsive: scope.responsive or undefined
rtl: scope.rtl is "true"
Expand All @@ -109,40 +106,40 @@ angular.module('slick', [])
nextArrow: if scope.nextArrow then $(scope.nextArrow) else undefined


slider.on 'init', (sl) ->
slider.on 'init', (event, slick) ->
scope.onInit() if attrs.onInit
if currentIndex?
sl.slideHandler(currentIndex)
slick.slideHandler(currentIndex)

slider.on 'reInit', (sl) ->
slider.on 'reInit', (event, slick) ->
scope.onReInit() if attrs.onReInit

slider.on 'setPosition', (sl) ->
slider.on 'setPosition', (event, slick) ->
scope.onSetPosition() if attrs.onSetPosition

slider.on 'swipe', (sl) ->
scope.onSwipe() if attrs.onSwipe
slider.on 'swipe', (event, slick, direction) ->
scope.onSwipe(direction) if attrs.onSwipe

slider.on 'afterChange', (event, slick, currentSlide, nextSlide) ->
scope.onAfterChange() if scope.onAfterChange
slider.on 'afterChange', (event, slick, currentSlide) ->
scope.onAfterChange(currentSlide) if scope.onAfterChange

if currentIndex?
scope.$apply(->
currentIndex = currentSlide
scope.currentIndex = currentSlide
)

slider.on 'beforeChange', (sl) ->
scope.onBeforeChange() if attrs.onBeforeChange
slider.on 'beforeChange', (event, slick, currentSlide, nextSlide) ->
scope.onBeforeChange(currentSlide, nextSlide) if attrs.onBeforeChange

slider.on 'breakpoint', (sl) ->
slider.on 'breakpoint', (event, slick) ->
scope.onBreakpoint() if attrs.onBreakpoint

slider.on 'destroy', (sl) ->
slider.on 'destroy', (event, slick) ->
scope.onDestroy() if attrs.onDestroy

slider.on 'edge', (sl) ->
scope.onEdge() if attrs.onEdge
slider.on 'edge', (event, slick, direction) ->
scope.onEdge(direction) if attrs.onEdge

scope.$watch("currentIndex", (newVal, oldVal) ->
if currentIndex? and newVal? and newVal != currentIndex
Expand Down

1 comment on commit 9e9e18c

@weberml2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle all Slick events with 1.4 event model, remove deprecated callbacks on init, and pass relevant event details to callbacks. Breaking change-- bind to callback function in order to pass information back to controller. Supersedes PR #100

Please sign in to comment.