summaryrefslogtreecommitdiff
path: root/assets/js
diff options
context:
space:
mode:
author阔落 <45323514+BigCoke233@users.noreply.github.com>2019-03-30 15:31:58 +0800
committerGitHub <noreply@github.com>2019-03-30 15:31:58 +0800
commit24ef0d2a0c9483879c195a76e77a477db3f6ca72 (patch)
treee2d4caec326b2d90624fb1aff163e7300d3a43ac /assets/js
parent9ae13dfa011baab12843b6855c2e9a4d6ca92075 (diff)
Add files via upload
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/id-transition.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/assets/js/id-transition.js b/assets/js/id-transition.js
new file mode 100644
index 0000000..9355b69
--- /dev/null
+++ b/assets/js/id-transition.js
@@ -0,0 +1,18 @@
+ $(function(){
+ //锚点跳转滑动效果
+ $('a[href*=#],area[href*=#]').click(function() {
+ console.log(this.pathname)
+ if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
+ var $target = $(this.hash);
+ $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
+ if ($target.length) {
+ var targetOffset = $target.offset().top;
+ $('html,body').animate({
+ scrollTop: targetOffset
+ },
+ 1000);
+ return false;
+ }
+ }
+ });
+ })