Skip to content

Commit

Permalink
fix loop bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuya Hashimoto committed Apr 16, 2013
1 parent c4f21df commit d0241d9
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 33 deletions.
32 changes: 15 additions & 17 deletions build/coffee/src/flickable.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
do (global = this, document = this.document, helper = new global.Flickable.Helper()) ->
do (global = this, document = this.document, helper = new Flickable.Helper()) ->

class Flickable
constructor: (element, opts = {}) ->
Expand All @@ -13,32 +13,30 @@ do (global = this, document = this.document, helper = new global.Flickable.Helpe
@el = document.querySelector(element)
else if not @el
throw new Error("Element Not Found")


# Variable Params
@currentPoint = @maxPoint = @currentX = @maxX = 0
@gestureStart = @moveReady = @scrolling = @didCloneNode = false

@startTime = @timerId =
@basePageX = @startPageX = @startPageY = @distance = null


# Set Options
@opts.use3d = if @opts.disable3d then false else @support.transform3d
@opts.useJsAnimate = false
@opts.disableTouch = @opts.disableTouch or false
@opts.disable3d = @opts.disable3d or false

@opts.autoPlay = @opts.autoPlay or false
@opts.interval = @opts.interval or 6600
@opts.loop = @opts.loop or if @opts.autoPlay then true else false

@opts.transition = @opts.transition or {}
@opts.transition =
timingFunction: @opts.transition["timingFunction"] or "cubic-bezier(0.23, 1, 0.32, 1)"
duration: do =>
timingFunction: @opts.transition["timingFunction"] or "cubic-bezier(0.23, 1, 0.32, 1)"
duration: do =>
@opts.transition["duration"] or if @browser.isLegacy then "200ms" else "330ms"

# Variable Params
@currentPoint = if @opts.currentPoint is undefined and @opts.loop then 1 else @opts.currentPoint or 0
@maxPoint = @currentX = @maxX = 0
# @currentPoint = @maxPoint = @currentX = @maxX = 0
@gestureStart = @moveReady = @scrolling = @didCloneNode = false

@startTime = @timerId =
@basePageX = @startPageX = @startPageY = @distance = null

if @support.cssAnimation
@helper.setStyle @el,
transitionProperty: @helper.getCSSVal("transform")
Expand Down Expand Up @@ -97,9 +95,9 @@ do (global = this, document = this.document, helper = new global.Flickable.Helpe

return itemLength

@maxPoint = if @opts.maxPoint is undefined then getMaxPoint() else @opts.maxPoint
@distance = if @opts.distance is undefined then @el.scrollWidth / (@maxPoint + 1) else @opts.distance
@maxX = -@distance * @maxPoint
@maxPoint = if @opts.maxPoint is undefined then getMaxPoint() else @opts.maxPoint
@distance = if @opts.distance is undefined then @el.scrollWidth / (@maxPoint + 1) else @opts.distance
@maxX = -@distance * @maxPoint

@moveToPoint()

Expand Down
7 changes: 7 additions & 0 deletions build/coffee/src/namespace.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
###
Flickable.js - based on flipsnap.js (http://pxgrid.github.com/js-flipsnap/)
Author: @yuya
Version: 0.1
###

do (root = this, factory = (global, document) ->
NS = "Flickable"

Expand Down
2 changes: 1 addition & 1 deletion build/coffee/test/flickable.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe "Flickable Class", ->
length = 5

while length
item = document.createElement "div"
item = document.createElement("div")
item.style.float = "left"
item.style.width = "100px"
element.appendChild(item)
Expand Down
16 changes: 5 additions & 11 deletions src/flickable-all.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions src/flickable.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/namespace.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d0241d9

Please sign in to comment.