Browse Source

adding new handle for offset

master
Björn 5 years ago
parent
commit
84d6d9bb27
3 changed files with 11 additions and 5 deletions
  1. +1
    -1
      dist/js/demo-386.js
  2. +1
    -1
      package.json
  3. +9
    -3
      src/TinyOnePage.riot

+ 1
- 1
dist/js/demo-386.js
File diff suppressed because it is too large
View File


+ 1
- 1
package.json View File

@ -1,6 +1,6 @@
{ {
"name": "tiny-one-page", "name": "tiny-one-page",
"version": "1.0.2",
"version": "1.0.3",
"description": "One Page Menu with RiotJS, part of Tiny-Components", "description": "One Page Menu with RiotJS, part of Tiny-Components",
"scripts": { "scripts": {
"dev": "npm run development", "dev": "npm run development",


+ 9
- 3
src/TinyOnePage.riot View File

@ -228,7 +228,13 @@
const elements = this.$$('.' + this.state.namespace + '__inner a'); const elements = this.$$('.' + this.state.namespace + '__inner a');
// @TODO check offset // @TODO check offset
const offset = this.state.options.offset - 25;
let offset = 25;
if (typeof this.state.options.offset === "function") {
offset = this.state.options.offset() - offset;
} else {
offset = this.state.options.offset - offset;
}
// if found // if found
let hasFound = false; let hasFound = false;
@ -237,9 +243,9 @@
let result = undefined; let result = undefined;
if (window.pageYOffset > offset) { if (window.pageYOffset > offset) {
document.querySelector('body').classList.add('is-scrolling');
document.querySelector('body').classList.add('has-scrolled');
} else { } else {
document.querySelector('body').classList.remove('is-scrolling');
document.querySelector('body').classList.remove('has-scrolled');
} }
elements.forEach(function(element, index) { elements.forEach(function(element, index) {


Loading…
Cancel
Save