Permalink
Browse files

Fixes

  • Loading branch information...
koenbok committed Jun 19, 2014
1 parent e3e38a1 commit 4235f0cab1bbf119d1270cfc10a8d6a48fdefe3e
Showing with 32 additions and 15 deletions.
  1. +5 −3 framer/Extras/MobileScrollFix.coffee
  2. +1 −1 framer/Framer.coffee
  3. +13 −11 framer/Layer.coffee
  4. +13 −0 test/init.coffee
@@ -24,6 +24,7 @@ exports.enable = ->
super options
@on "change:scrollVertical", @_updateScrollListeners

This comment has been minimized.

@tisho

tisho Jun 19, 2014

Contributor

You might want to double check this, but I think change:* fires regardless of whether the value has changed or not. This means that repeatedly setting scrollVertical to true on a layer would result in multiple listeners getting added. This is why in the original scripts I always call @off without even checking if scrollVertical is true.

@_updateScrollListeners()
_updateScrollListeners: =>
if @scrollVertical is true
@@ -35,11 +36,12 @@ exports.enable = ->
__createRootElement: =>
element = super
element.addEventListener "touchmove", (event) ->
rootElement = super
rootElement.addEventListener "touchmove", (event) ->
event.preventDefault()
return element
return rootElement
# Override the standard window Layer with this patched one
window.Layer = window.Framer.Layer = MobileScrollFixLayer
@@ -36,7 +36,7 @@ window.Framer = Framer if window
require "./Compat"
# Fix for mobile scrolling
Framer.Extras.MobileScrollFix.enable() if Utils.isMobile
Framer.Extras.MobileScrollFix.enable() if Utils.isMobile()
# Set the defaults
Defaults = (require "./Defaults").Defaults
@@ -563,7 +563,7 @@ class exports.Layer extends BaseClass
##############################################################
## EVENTS
addListener: (event, originalListener) =>
addListener: (eventName, originalListener) =>
# # Modify the scope to be the calling object, just like jquery
# # also add the object as the last argument
@@ -575,29 +575,31 @@ class exports.Layer extends BaseClass
originalListener.modifiedListener = listener
# Listen to dom events on the element
super event, listener
@_element.addEventListener event, listener
super eventName, listener
@_element.addEventListener eventName, listener
@_eventListeners ?= {}
@_eventListeners[event] ?= []
@_eventListeners[event].push listener
@_eventListeners[eventName] ?= []
@_eventListeners[eventName].push listener
# We want to make sure we listen to these events
@ignoreEvents = false
# We want to make sure we listen to these events, but we can safely
# ignore it for change events
if not _.startsWith eventName, "change:"
@ignoreEvents = false
removeListener: (event, listener) ->
removeListener: (eventName, listener) ->
# If the original listener was modified, remove that
# one instead
if listener.modifiedListener
listener = listener.modifiedListener
super event, listener
super eventName, listener
@_element.removeEventListener event, listener
@_element.removeEventListener eventName, listener
if @_eventListeners
@_eventListeners[event] = _.without @_eventListeners[event], listener
@_eventListeners[eventName] = _.without @_eventListeners[eventName], listener
removeAllListeners: ->
@@ -1,5 +1,18 @@
window.console.debug = (v) ->
hideFramerRoot = ->
element = document.getElementById "FramerRoot"
if not element
return Utils.delay 0.01, hideFramerRoot
_.extend element.style,
top: "-10000000px"
left: "-10000000px"
hideFramerRoot()
require "./tests/EventEmitterTest"
require "./tests/UtilsTest"
require "./tests/BaseClassTest"

0 comments on commit 4235f0c

Please sign in to comment.