Skip to content

Commit

Permalink
maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpflug committed Sep 23, 2016
1 parent 29c1d07 commit f992e17
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 104 deletions.
29 changes: 0 additions & 29 deletions index.js

This file was deleted.

6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -8,7 +8,7 @@
"email": "paul.pflugradt@gmail.com"
},
"license": "MIT",
"main": "index.js",
"main": "build/bundle.js",
"repository": {
"type": "git",
"url": "git://github.com/paulpflug/vue-mixins"
Expand Down Expand Up @@ -49,8 +49,8 @@
"build": "run-npm build:*",
"watch": "karma start --browsers Chromium --auto-watch --reporters spec",
"test": "karma start --single-run",
"preversion": "npm test",
"version": "npm run build && git add .",
"preversion": "npm test && npm run build",
"version": "git add .",
"postversion": "git push && git push --tags && npm publish"
}
}
21 changes: 21 additions & 0 deletions src/_throttledListener.coffee
@@ -0,0 +1,21 @@
# out: ../_throttledListener.js
throttle = require("lodash/throttle")
rAF = window.requestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame

cAF = window.cancelAnimationFrame ||
window.mozCancelAnimationFrame
if rAF
fn = (event, cb) ->
lastRequest = null
window.addEventListener event, ->
args = arguments
cAF(lastRequest)
lastRequest = rAF -> cb.apply(null, args)
else
throttle = require("lodash/throttle")
fn = (event, cb) ->
window.addEventListener event, throttle(cb, 66)
module.exports = fn
14 changes: 4 additions & 10 deletions src/onElementResize.coffee
Expand Up @@ -2,21 +2,15 @@

hasMutationObserver = !!window.MutationObserver
if hasMutationObserver
resizeRunning = false

allResizeCbs = []
resizeHandler = ->
unless resizeRunning
resizeRunning = true
if window.requestAnimationFrame
window.requestAnimationFrame callResizeCbs
else
setTimeout callResizeCbs, 66
callResizeCbs = (e) ->
for cb in allResizeCbs
cb(e)
resizeRunning = false
window.addEventListener "resize", resizeHandler
observer = new MutationObserver resizeHandler
require("./_throttledListener")("resize",callResizeCbs)
throttle = require("lodash/throttle")
observer = new MutationObserver throttle(callResizeCbs,66)
observer.observe document.body,
attributes: true
childList: true
Expand Down
20 changes: 1 addition & 19 deletions src/onMouseMove.coffee
Expand Up @@ -3,25 +3,7 @@ allMouseMoveCbs = []
callMouseMoveCbs = ->
for cb in allMouseMoveCbs
cb.apply(null,arguments)
rAF = window.requestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame

cAF = window.cancelAnimationFrame ||
window.mozCancelAnimationFrame

if rAF?
lastRequest = null
window.addEventListener "mousemove", ->
args = arguments
cAF(lastRequest)
lastRequest = rAF -> callMouseMoveCbs.apply(null,args)
else
throttle = require("lodash/throttle")
window.addEventListener "mousemove", throttle(callMouseMoveCbs,66)


require("./_throttledListener")("mousemove",callMouseMoveCbs)
module.exports =
data: ->
mouseMoveCbDisposables: []
Expand Down
17 changes: 1 addition & 16 deletions src/onWindowResize.coffee
Expand Up @@ -4,22 +4,7 @@ callResizeCbs = ->
for cb in allResizeCbs
cb.apply(null,arguments)
resizeRunning = false
rAF = window.requestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame

cAF = window.cancelAnimationFrame ||
window.mozCancelAnimationFrame
if rAF
lastRequest = null
window.addEventListener "resize", ->
args = arguments
cAF(lastRequest)
lastRequest = rAF -> callResizeCbs.apply(null,args)
else
throttle = require("lodash/throttle")
window.addEventListener "resize", throttle(callResizeCbs,66)
require("./_throttledListener")("resize",callResizeCbs)

module.exports =
data: ->
Expand Down
17 changes: 1 addition & 16 deletions src/onWindowScroll.coffee
Expand Up @@ -3,22 +3,7 @@ allScrollCbs = []
callScrollCbs = ->
for cb in allScrollCbs
cb.apply(null,arguments)
rAF = window.requestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame

cAF = window.cancelAnimationFrame ||
window.mozCancelAnimationFrame
if rAF
lastRequest = null
window.addEventListener "scroll", ->
args = arguments
cAF(lastRequest)
lastRequest = rAF -> callScrollCbs.apply(null,args)
else
throttle = require("lodash/throttle")
window.addEventListener "scroll", throttle(callScrollCbs,66)
require("./_throttledListener")("scroll",callScrollCbs)


module.exports =
Expand Down
10 changes: 10 additions & 0 deletions webpack.config.coffee
@@ -0,0 +1,10 @@
webpack = require('webpack')

module.exports = {
entry: "./build/index.js"
output:
filename: "./build/bundle.js"
plugins: [
new webpack.optimize.UglifyJsPlugin compress: warnings: false
]
}
11 changes: 0 additions & 11 deletions webpack.config.js

This file was deleted.

0 comments on commit f992e17

Please sign in to comment.