mirror of
https://github.com/kamranahmedse/driver.js.git
synced 2026-11-02 22:17:14 +08:00
add scroll into view options
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -5,7 +5,7 @@
|
||||
"main": "./assets/scripts/dist/driver.min.js",
|
||||
"scripts": {
|
||||
"start": "node server.js",
|
||||
"build": "webpack --config webpack.config.prod.js "
|
||||
"build": "webpack --config webpack.config.prod.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/kamranahmedse/driver.js/issues"
|
||||
|
||||
+5
-4
@@ -79,11 +79,12 @@ export default class Element {
|
||||
return;
|
||||
}
|
||||
|
||||
const elementRect = this.node.getBoundingClientRect();
|
||||
const absoluteElementTop = elementRect.top + this.window.pageYOffset;
|
||||
const middle = absoluteElementTop - (this.window.innerHeight / 2);
|
||||
const scrollIntoViewOptions = this.options.scrollIntoViewOptions || {
|
||||
behavior: 'smooth',
|
||||
block: 'center',
|
||||
};
|
||||
|
||||
this.window.scrollTo(0, middle);
|
||||
this.node.scrollIntoView(scrollIntoViewOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user