(options = {})
| 28 | let instance |
| 29 | |
| 30 | export default function ScrollReveal(options = {}) { |
| 31 | const invokedWithoutNew = |
| 32 | typeof this === 'undefined' || |
| 33 | Object.getPrototypeOf(this) !== ScrollReveal.prototype |
| 34 | |
| 35 | if (invokedWithoutNew) { |
| 36 | return new ScrollReveal(options) |
| 37 | } |
| 38 | |
| 39 | if (!ScrollReveal.isSupported()) { |
| 40 | logger.call(this, 'Instantiation failed.', 'This browser is not supported.') |
| 41 | return mount.failure() |
| 42 | } |
| 43 | |
| 44 | let buffer |
| 45 | try { |
| 46 | buffer = config |
| 47 | ? deepAssign({}, config, options) |
| 48 | : deepAssign({}, defaults, options) |
| 49 | } catch (e) { |
| 50 | logger.call(this, 'Invalid configuration.', e.message) |
| 51 | return mount.failure() |
| 52 | } |
| 53 | |
| 54 | try { |
| 55 | const container = $(buffer.container)[0] |
| 56 | if (!container) { |
| 57 | throw new Error('Invalid container.') |
| 58 | } |
| 59 | } catch (e) { |
| 60 | logger.call(this, e.message) |
| 61 | return mount.failure() |
| 62 | } |
| 63 | |
| 64 | config = buffer |
| 65 | |
| 66 | if ((!config.mobile && isMobile()) || (!config.desktop && !isMobile())) { |
| 67 | logger.call( |
| 68 | this, |
| 69 | 'This device is disabled.', |
| 70 | `desktop: ${config.desktop}`, |
| 71 | `mobile: ${config.mobile}` |
| 72 | ) |
| 73 | return mount.failure() |
| 74 | } |
| 75 | |
| 76 | mount.success() |
| 77 | |
| 78 | this.store = { |
| 79 | containers: {}, |
| 80 | elements: {}, |
| 81 | history: [], |
| 82 | sequences: {} |
| 83 | } |
| 84 | |
| 85 | this.pristine = true |
| 86 | |
| 87 | boundDelegate = boundDelegate || delegate.bind(this) |
no test coverage detected