You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2019/12/23 14:12:48 UTC

[incubator-echarts-doc] branch release updated: replace vue-scrollto with scroll-into-view

This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch release
in repository https://gitbox.apache.org/repos/asf/incubator-echarts-doc.git


The following commit(s) were added to refs/heads/release by this push:
     new 9f670c0  replace vue-scrollto with scroll-into-view
9f670c0 is described below

commit 9f670c0d33a7b52dc05153d30713a4c4ca828399
Author: pissang <bm...@gmail.com>
AuthorDate: Mon Dec 23 22:12:33 2019 +0800

    replace vue-scrollto with scroll-into-view
---
 package-lock.json             | 18 +++++-------------
 package.json                  |  2 +-
 src/components/DocContent.vue | 16 +++++++---------
 src/components/DocNav.vue     | 15 ++++++++++-----
 4 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index 846c9f5..f221230 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1755,11 +1755,6 @@
       "integrity": "sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY=",
       "dev": true
     },
-    "bezier-easing": {
-      "version": "2.1.0",
-      "resolved": "https://registry.npmjs.org/bezier-easing/-/bezier-easing-2.1.0.tgz",
-      "integrity": "sha1-wE3+i5JtbsrKGBPWn/F5t8ICXYY="
-    },
     "big.js": {
       "version": "5.2.2",
       "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
@@ -10642,6 +10637,11 @@
         }
       }
     },
+    "scroll-into-view": {
+      "version": "1.14.0",
+      "resolved": "https://registry.npmjs.org/scroll-into-view/-/scroll-into-view-1.14.0.tgz",
+      "integrity": "sha512-SJolYUM4Uk1Ppaiq8gTKdcm13uHtg8KFYWNlZg0CutxuSWQu2vLVukH/KUrnhxhtpl5A4I1uTRjV5Jwu9x/NGA=="
+    },
     "select-hose": {
       "version": "2.0.0",
       "resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz",
@@ -11837,14 +11837,6 @@
         "vue-style-loader": "^4.1.0"
       }
     },
-    "vue-scrollto": {
-      "version": "2.17.1",
-      "resolved": "https://registry.npmjs.org/vue-scrollto/-/vue-scrollto-2.17.1.tgz",
-      "integrity": "sha512-uxOJXg6cZL88B+hTXRHDJMR+gHGiaS70ZTNk55fE5Z2TdwyIx9K/IHoNeTrtBrM6u3FASAIymKjZaQLmDf8Ykg==",
-      "requires": {
-        "bezier-easing": "2.1.0"
-      }
-    },
     "vue-style-loader": {
       "version": "4.1.2",
       "resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.2.tgz",
diff --git a/package.json b/package.json
index b6ac642..0684de7 100644
--- a/package.json
+++ b/package.json
@@ -53,12 +53,12 @@
     "lodash.debounce": "^4.0.8",
     "lodash.throttle": "^4.1.1",
     "mark.js": "^8.11.1",
+    "scroll-into-view": "^1.14.0",
     "string-similarity-js": "^2.1.2",
     "vanilla-lazyload": "^12.3.0",
     "vue": "^2.6.10",
     "vue-custom-scrollbar": "^1.1.0",
     "vue-i18n": "^8.15.0",
-    "vue-scrollto": "^2.17.1",
     "vue-text-highlight": "^2.0.10",
     "whatwg-fetch": "^3.0.0"
   }
diff --git a/src/components/DocContent.vue b/src/components/DocContent.vue
index 610599e..cd91ee2 100644
--- a/src/components/DocContent.vue
+++ b/src/components/DocContent.vue
@@ -20,8 +20,6 @@
                 @toggle-expanded="handleCardExpandToggle"
             ></DocContentItemCard>
         </div>
-
-    </div>
     </div>
 </template>
 
@@ -39,7 +37,7 @@ import {
 import {store, getPagePath} from '../store';
 import {directTo} from '../route';
 import DocContentItemCard from './DocContentItemCard.vue'
-import VueScrollTo from 'vue-scrollto';
+import scrollIntoView from 'scroll-into-view';
 import Vue from 'vue';
 import LazyLoad from 'vanilla-lazyload';
 
@@ -117,13 +115,13 @@ export default {
                 let container = store.isMobile ? document.body : this.$el.parentNode;
                 let offset = store.isMobile ? -100 : -20;
                 // console.log(document.querySelector('#' + convertPathToId(path)), convertPathToId(path));
-                VueScrollTo.scrollTo(
-                    '#' + convertPathToId(path), time || 400, {
-                        offset,
-                        easing: 'ease-in-out',
-                        container
+                scrollIntoView(document.querySelector('#' + convertPathToId(path)), {
+                    time: time || 400,
+                    align: {
+                        top: 0,
+                        topOffset: -offset
                     }
-                );
+                });
             }, timeDelay || 0);
         },
 
diff --git a/src/components/DocNav.vue b/src/components/DocNav.vue
index 3a4e633..dfdfc7d 100644
--- a/src/components/DocNav.vue
+++ b/src/components/DocNav.vue
@@ -41,7 +41,8 @@ import {getOutlineAsync} from '../docHelper';
 import {store, isOptionDoc} from '../store';
 import Vue from 'vue';
 import {directTo} from '../route';
-import VueScrollTo from 'vue-scrollto';
+import scrollIntoView from 'scroll-into-view';
+
 
 function joinPath(a, b, connector) {
     return a ? (a + connector + b) : b;
@@ -175,10 +176,14 @@ export default {
                 let nodeRect = node.getBoundingClientRect();
                 let rootRect = this.$el.getBoundingClientRect();
                 if (nodeRect.top > rootRect.bottom || nodeRect.bottom < rootRect.top) {   // Not visible
-                    VueScrollTo.scrollTo(node, 500, {
-                        offset: -20,
-                        easing: 'ease-in-out',
-                        container: this.$el
+                    // node.scrollIntoView(true, {
+                    //     behavior: 'smooth'
+                    // });
+                    scrollIntoView(node, {
+                        time: 500,
+                        align: {
+                            top: 0.1
+                        }
                     });
                 }
             }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org