kdf
Version:
73 lines (45 loc) • 1.77 kB
text/coffeescript
KDCustomHTMLView = require './../../core/customhtmlview'
KDScrollView = require './scrollview'
KDScrollThumb = require './scrollthumb'
KDScrollTrack = require './scrolltrack'
module.exports = class KDCustomScrollViewWrapper extends KDScrollView
scroll: (event) ->
if .beingDragged or .beingDragged
return KD.utils.stopDOMEvent event
mouseWheel: (event) ->
super
{deltaX, deltaY, deltaFactor} = event
speed = deltaFactor or .mouseWheelSpeed or 1
x = -deltaX
y = -deltaY
resX = if x isnt 0 and > .getTrackSize()
then {speed, velocity : x}
else no
resY = if y isnt 0 and > .getTrackSize()
then {speed, velocity : y}
else no
stop = if Math.abs(x) > Math.abs(y) then resX else resY
KD.utils.stopDOMEvent event unless stop
return !stop
_scrollVertically: do ->
lastPosition = 0
({speed, velocity})->
stepInPixels = velocity * speed
actPosition =
newPosition = actPosition + stepInPixels
shouldStop = if velocity > 0
then lastPosition > newPosition
else lastPosition < newPosition
lastPosition = newPosition
return shouldStop
_scrollHorizontally: do ->
lastPosition = 0
({speed, velocity})->
stepInPixels = velocity * speed
actPosition =
newPosition = actPosition - stepInPixels
shouldStop = if velocity > 0
then lastPosition < newPosition
else lastPosition > newPosition
lastPosition = newPosition
return shouldStop