Skip to content
Permalink
Browse files

Check scrollX, scrollY value type

  • Loading branch information
koenbok committed Sep 25, 2014
1 parent d8c6123 commit bf0e721ab82b849c461ae318c0a7a9ca6fe44124
Showing with 10 additions and 55 deletions.
  1. +0 −52 extras/CactusFramer/static/app.coffee
  2. +10 −3 framer/Layer.coffee
@@ -1,52 +1,3 @@
document.ontouchmove = (event) ->
if event.target is document.body
event.preventDefault()
#event.preventDefault()
#event.stopPropagation()
#event.stopImmediatePropagation()


# checkIfElementShouldScroll = (element) ->
# print typeof element
# return true

# document.ontouchmove = (e) ->

# target = e.currentTarget

# while (target)

# if checkIfElementShouldScroll(target)
# return

# target = target.parentNode

# e.preventDefault()


ScrollFix = (elem) ->

# Variables to track inputs
startY = undefined
startTopScroll = undefined
elem = elem or document.querySelector(elem)

# If there is no element, then do nothing
return unless elem

# Handle the start of interactions
elem.addEventListener "touchstart", ((event) ->
startY = event.touches[0].pageY
startTopScroll = elem.scrollTop
elem.scrollTop = 1 if startTopScroll <= 0
elem.scrollTop = elem.scrollHeight - elem.offsetHeight - 1 if startTopScroll + elem.offsetHeight >= elem.scrollHeight
return
), false
return




margin = 300

scrollingLayer = new Layer
@@ -61,6 +12,3 @@ contentLayer = new Layer

scrollingLayer.center()
scrollingLayer.scrollVertical = true


ScrollFix(document)
@@ -12,6 +12,9 @@ Utils = require "./Utils"
{LayerStates} = require "./LayerStates"
{LayerDraggable} = require "./LayerDraggable"

layerValueTypeError = (name, value) ->
throw new Error("Layer.#{name}: value '#{value}' of type '#{typeof(value)}'' is not valid")

layerProperty = (obj, name, cssProperty, fallback, validator, set) ->
result =
exportable: true
@@ -22,7 +25,7 @@ layerProperty = (obj, name, cssProperty, fallback, validator, set) ->
set: (value) ->

if value and validator and not validator(value)
throw new Error("Layer.#{name}: value '#{value}' of type '#{typeof(value)}'' is not valid")
layerValueTypeError(name, value)

@_properties[name] = value
@_element.style[cssProperty] = LayerStyle[cssProperty](@)
@@ -622,11 +625,15 @@ class exports.Layer extends BaseClass

@define "scrollX",
get: -> @_element.scrollLeft
set: (value) -> @_element.scrollLeft = value
set: (value) ->
layerValueTypeError("scrollX", value) if not _.isNumber(value)
@_element.scrollLeft = value

@define "scrollY",
get: -> @_element.scrollTop
set: (value) -> @_element.scrollTop = value
set: (value) ->
layerValueTypeError("scrollY", value) if not _.isNumber(value)
@_element.scrollTop = value

##############################################################
## EVENTS

0 comments on commit bf0e721

Please sign in to comment.