Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions js/miniSlider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#
class Slide
constructor: (@element, @index, @options) ->
@element.css { position: 'absolute', top: 0, left: @index * @element.width() }
@element.css
top: 0
position: 'absolute'
width: (100 / @numberOfSlides) + '%'
left: ((100 / @numberOfSlides) * @index) + '%'

class Slider
constructor: (@container, @options) ->
Expand Down Expand Up @@ -63,10 +67,11 @@ class Slider
initSlides: ->
# Create array of slide objects
@slides = []
@numberOfSlides = @container.children().length
@container.children().each (index, element) =>
@slides.push(new Slide($(element), index, @options))

@container.css('width', @size.width * @slides.length)
@container.css('width', (100 * @slides.length) + '%')
@initTracker()

currentSlideElement: -> @slideElementForIndex @currentIndex
Expand Down Expand Up @@ -142,7 +147,7 @@ class Slider
@state = 'animating'
@callAnimationCallbackFunction 'onTransition', index

@container.animate({ left: 0 - (@size.width * index) }, @options.transitionSpeed, @options.transitionEasing, =>
@container.animate({ left: 0 - (100 * index) + '%' }, @options.transitionSpeed, @options.transitionEasing, =>
@updateTracker index
@state = 'waiting'
@callAnimationCallbackFunction 'onComplete', index
Expand Down