Commit a86fd703 authored by Robert Knight's avatar Robert Knight

Remove unnecessary requestAnimationFrame polyfill

requestAnimationFrame is supported natively [1] by all the browsers we
support.

[1] https://caniuse.com/#search=requestanimationframe
parent 2134e05c
...@@ -85,7 +85,6 @@ ...@@ -85,7 +85,6 @@
"prettier": "1.19.1", "prettier": "1.19.1",
"puppeteer": "^2.0.0", "puppeteer": "^2.0.0",
"query-string": "^3.0.1", "query-string": "^3.0.1",
"raf": "^3.1.0",
"redux": "^4.0.1", "redux": "^4.0.1",
"redux-thunk": "^2.1.0", "redux-thunk": "^2.1.0",
"reselect": "^4.0.0", "reselect": "^4.0.0",
......
raf = require('raf')
scrollIntoView = require('scroll-into-view') scrollIntoView = require('scroll-into-view')
CustomEvent = require('custom-event') CustomEvent = require('custom-event')
...@@ -15,7 +14,7 @@ xpathRange = require('./anchoring/range') ...@@ -15,7 +14,7 @@ xpathRange = require('./anchoring/range')
animationPromise = (fn) -> animationPromise = (fn) ->
return new Promise (resolve, reject) -> return new Promise (resolve, reject) ->
raf -> requestAnimationFrame ->
try try
resolve(fn()) resolve(fn())
catch error catch error
...@@ -295,7 +294,7 @@ module.exports = class Guest extends Delegator ...@@ -295,7 +294,7 @@ module.exports = class Guest extends Delegator
self.anchors.push(anchor) self.anchors.push(anchor)
# Remove all the highlights that have no corresponding target anymore. # Remove all the highlights that have no corresponding target anymore.
raf -> highlighter.removeHighlights(deadHighlights) requestAnimationFrame -> highlighter.removeHighlights(deadHighlights)
# Anchor any targets of this annotation that are not anchored already. # Anchor any targets of this annotation that are not anchored already.
for target in annotation.target when target not in anchoredTargets for target in annotation.target when target not in anchoredTargets
...@@ -318,7 +317,7 @@ module.exports = class Guest extends Delegator ...@@ -318,7 +317,7 @@ module.exports = class Guest extends Delegator
this.anchors = anchors this.anchors = anchors
unhighlight = Array::concat(unhighlight...) unhighlight = Array::concat(unhighlight...)
raf => requestAnimationFrame =>
highlighter.removeHighlights(unhighlight) highlighter.removeHighlights(unhighlight)
this.plugins.BucketBar?.update() this.plugins.BucketBar?.update()
......
raf = require('raf')
$ = require('jquery') $ = require('jquery')
Plugin = require('../plugin') Plugin = require('../plugin')
...@@ -101,7 +99,7 @@ module.exports = class BucketBar extends Plugin ...@@ -101,7 +99,7 @@ module.exports = class BucketBar extends Plugin
# Update sometime soon # Update sometime soon
update: => update: =>
return if @_updatePending? return if @_updatePending?
@_updatePending = raf => @_updatePending = requestAnimationFrame =>
delete @_updatePending delete @_updatePending
@_update() @_update()
......
raf = require('raf')
Hammer = require('hammerjs') Hammer = require('hammerjs')
Host = require('./host') Host = require('./host')
...@@ -130,7 +129,7 @@ module.exports = class Sidebar extends Host ...@@ -130,7 +129,7 @@ module.exports = class Sidebar extends Host
return if @renderFrame return if @renderFrame
# Schedule a frame # Schedule a frame
@renderFrame = raf => @renderFrame = requestAnimationFrame =>
@renderFrame = null # Clear the schedule @renderFrame = null # Clear the schedule
# Process the resize gesture # Process the resize gesture
......
...@@ -11,9 +11,6 @@ Guest = require('../guest') ...@@ -11,9 +11,6 @@ Guest = require('../guest')
rangeUtil = null rangeUtil = null
selections = null selections = null
raf = sinon.stub().yields()
raf['@noCallThru'] = true
scrollIntoView = sinon.stub() scrollIntoView = sinon.stub()
scrollIntoView['@noCallThru'] = true scrollIntoView['@noCallThru'] = true
...@@ -75,6 +72,8 @@ describe 'Guest', -> ...@@ -75,6 +72,8 @@ describe 'Guest', ->
anchor: sinon.stub() anchor: sinon.stub()
} }
sinon.stub(window, 'requestAnimationFrame').yields()
$imports.$mock({ $imports.$mock({
'./adder': {Adder: FakeAdder}, './adder': {Adder: FakeAdder},
'./anchoring/html': htmlAnchoring, './anchoring/html': htmlAnchoring,
...@@ -86,7 +85,6 @@ describe 'Guest', -> ...@@ -86,7 +85,6 @@ describe 'Guest', ->
return () -> return () ->
) )
'./delegator': Delegator, './delegator': Delegator,
'raf': raf,
'scroll-into-view': scrollIntoView, 'scroll-into-view': scrollIntoView,
}) })
...@@ -102,6 +100,7 @@ describe 'Guest', -> ...@@ -102,6 +100,7 @@ describe 'Guest', ->
guestConfig.pluginClasses['CrossFrame'] = CrossFrame guestConfig.pluginClasses['CrossFrame'] = CrossFrame
afterEach -> afterEach ->
window.requestAnimationFrame.restore()
sandbox.restore() sandbox.restore()
console.warn.restore() console.warn.restore()
$imports.$restore() $imports.$restore()
......
...@@ -14,11 +14,10 @@ describe 'Sidebar', -> ...@@ -14,11 +14,10 @@ describe 'Sidebar', ->
sidebarConfig = {pluginClasses: {}} sidebarConfig = {pluginClasses: {}}
before -> before ->
rafStub = (fn) -> sinon.stub(window, 'requestAnimationFrame').yields()
fn()
$imports.$mock({ raf: rafStub })
after -> after ->
window.requestAnimationFrame.restore();
$imports.$restore() $imports.$restore()
createSidebar = (config={}) -> createSidebar = (config={}) ->
......
...@@ -6380,7 +6380,7 @@ querystring@0.2.0, querystring@^0.2.0: ...@@ -6380,7 +6380,7 @@ querystring@0.2.0, querystring@^0.2.0:
resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620"
integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA= integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=
raf@^3.1.0, raf@^3.4.1: raf@^3.4.1:
version "3.4.1" version "3.4.1"
resolved "https://registry.yarnpkg.com/raf/-/raf-3.4.1.tgz#0742e99a4a6552f445d73e3ee0328af0ff1ede39" resolved "https://registry.yarnpkg.com/raf/-/raf-3.4.1.tgz#0742e99a4a6552f445d73e3ee0328af0ff1ede39"
integrity sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA== integrity sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment