Skip to content

Commit

Permalink
fix: Fix stroke shimmering on safari.
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinRoy committed Jul 28, 2017
1 parent 2779c4f commit f5e6ca1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/connect-navigation-to-layout.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import rafThrottle from 'raf-throttle';

/**
* Connect navigation notifications to menu opening and closing.
*
Expand Down Expand Up @@ -41,16 +43,16 @@ export default (
strokeStart = position;
};

const noviceMove = position => {
const noviceMove = rafThrottle(position => {
strokeCanvas.clear();
strokeCanvas.drawStroke([strokeStart, position]);
strokeCanvas.drawPoint(strokeStart);
};
});

const expertDraw = stroke => {
const expertDraw = rafThrottle(stroke => {
strokeCanvas.clear();
strokeCanvas.drawStroke(stroke);
};
});

const clearStroke = () => {
strokeCanvas.remove();
Expand Down
6 changes: 2 additions & 4 deletions src/layout/stroke.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import rafThrottle from 'raf-throttle';

const devicePixelRatio = window.devicePixelRatio || 1;

/**
Expand Down Expand Up @@ -73,7 +71,7 @@ export default (
* @param {List<number[]>} stroke - The new stroke.
* @return {undefined}
*/
const drawStroke = rafThrottle(stroke => {
const drawStroke = stroke => {
ctx.save();
ctx.fillStyle = 'none';
ctx.lineJoin = 'round';
Expand All @@ -86,7 +84,7 @@ export default (
});
ctx.stroke();
ctx.restore();
});
};

/**
* Destroy the canvas.
Expand Down

0 comments on commit f5e6ca1

Please sign in to comment.