Skip to content

Commit 346f3bf

Browse files
amhofnysherwinski
authored andcommitted
fix: ensure that handleTouch & injectBaseStyles can be disabled (#221)
1 parent 96c3344 commit 346f3bf

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/js/Drift.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default class Drift {
4444
// if `false`, it will switch to inline when `windowWidth <= inlinePane`
4545
const inlinePane = options["inlinePane"] || 375;
4646
// If `true`, touch events will trigger the zoom, like mouse events.
47-
const handleTouch = options["handleTouch"] || true;
47+
const handleTouch = "handleTouch" in options ? !!options["handleTouch"] : true;
4848
// If present (and a function), this will be called
4949
// whenever the ZoomPane is shown.
5050
const onShow = options["onShow"] || null;
@@ -53,7 +53,7 @@ export default class Drift {
5353
const onHide = options["onHide"] || null;
5454
// Add base styles to the page. See the "Theming"
5555
// section of README.md for more information.
56-
const injectBaseStyles = options["injectBaseStyles"] || true;
56+
const injectBaseStyles = "injectBaseStyles" in options ? !!options["injectBaseStyles"] : true;
5757
// An optional number that determines how long to wait before
5858
// showing the ZoomPane because of a `mouseenter` event.
5959
const hoverDelay = options["hoverDelay"] || 0;

test/testDrift.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ describe("Drift", () => {
5757

5858
it("accepts custom settings", () => {
5959
const anchor = document.querySelector(".test-anchor");
60-
const drift = new Drift(anchor, { inlineOffsetX: 12 });
60+
const drift = new Drift(anchor, { inlineOffsetX: 12, handleTouch: false, injectBaseStyles: false });
6161

6262
const expectedConfig = defaultDriftConfig();
6363
expectedConfig.inlineOffsetX = 12;
64+
expectedConfig.handleTouch = false;
65+
expectedConfig.injectBaseStyles = false;
6466

6567
expect(drift.settings).toEqual(expectedConfig);
6668
});

0 commit comments

Comments
 (0)