Skip to content

Commit 586440c

Browse files
committed
added support for boolean in disableParallax and disableVideo options (resolves #225)
1 parent 944b3bb commit 586440c

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ imgRepeat | string | `no-repeat` | Image repeat. Supported only `background-posi
261261
keepImg | boolean | `false` | Keep `<img>` tag in it's default place after Jarallax inited.
262262
elementInViewport | dom | `null` | Use custom DOM / jQuery element to check if parallax block in viewport. More info here - [Issue 13](https://github.com/nk-o/jarallax/issues/13).
263263
zIndex | number | `-100` | z-index of parallax container.
264-
disableParallax | RegExp / function | - | Disable parallax on specific user agents (using regular expression) or with function return value. The image will be set on the background.
264+
disableParallax | boolean / RegExp / function | - | Disable parallax on specific user agents (using regular expression) or with function return value. The image will be set on the background.
265265

266266
### Disable on mobile devices
267267

@@ -302,7 +302,7 @@ videoEndTime | float | `0` | End time in seconds when video will be ended.
302302
videoLoop | boolean | `true` | Loop video to play infinitely.
303303
videoPlayOnlyVisible | boolean | `true` | Play video only when it is visible on the screen.
304304
videoLazyLoading | boolean | `true` | Preload videos only when it is visible on the screen.
305-
disableVideo | RegExp / function | - | Disable video load on specific user agents (using regular expression) or with function return value. The image will be set on the background.
305+
disableVideo | boolean / RegExp / function | - | Disable video load on specific user agents (using regular expression) or with function return value. The image will be set on the background.
306306

307307
## Events
308308

src/core.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ class Jarallax {
5757
self.options.disableParallax = () => disableParallaxRegexp.test(navigator.userAgent);
5858
}
5959
if (typeof self.options.disableParallax !== 'function') {
60-
self.options.disableParallax = () => false;
60+
// Support for `true` option value.
61+
const disableParallaxDefault = self.options.disableParallax;
62+
self.options.disableParallax = () => disableParallaxDefault === true;
6163
}
6264

6365
// prepare disableVideo callback
@@ -69,7 +71,9 @@ class Jarallax {
6971
self.options.disableVideo = () => disableVideoRegexp.test(navigator.userAgent);
7072
}
7173
if (typeof self.options.disableVideo !== 'function') {
72-
self.options.disableVideo = () => false;
74+
// Support for `true` option value.
75+
const disableVideoDefault = self.options.disableVideo;
76+
self.options.disableVideo = () => disableVideoDefault === true;
7377
}
7478

7579
// custom element to check if parallax in viewport

typings/index.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export interface JarallaxOptions {
8686
* Disable parallax on specific user agents (using regular expression) or with function return value.
8787
* The image will be set on the background.
8888
*/
89-
disableParallax?: RegExp;
89+
disableParallax?: boolean | RegExp | function;
9090

9191
/**
9292
* Called when parallax working. Use first argument with calculations.
@@ -157,7 +157,7 @@ export interface JarallaxOptions {
157157
* Disable video load on specific user agents (using regular expression) or with function return value.
158158
* The image will be set on the background.
159159
*/
160-
disableVideo?: RegExp;
160+
disableVideo?: boolean | RegExp | function;
161161

162162
/**
163163
* Called right after video is inserted in the parallax block. Video can be accessed by `this.$video`
@@ -186,7 +186,7 @@ export function jarallax(
186186
*
187187
* @param {typeof jarallax} jarallaxInstance
188188
*/
189-
export function jarallaxVideo(jarallaxInstance?: typeof jarallax): void
189+
export function jarallaxVideo(jarallaxInstance?: typeof jarallax): void;
190190

191191
/**
192192
* Void callable methods

0 commit comments

Comments
 (0)