-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscroll-link.html
54 lines (47 loc) · 1.07 KB
/
scroll-link.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<link rel="import" href="../polymer/polymer.html">
<!--
`scroll-link`
Smooth Scroll behavior
@demo demo/index.html WIP
-->
<dom-module id="scroll-link">
<template>
<style>
:host {
display: var(--scroll-link-display, block);
cursor:pointer;
}
</style>
<a href="{{href}}" title="{{title}}">
<content></content>
</a>
</template>
<script src="../smoothscroll/dist/smoothscroll.js"></script>
<script>
Polymer({
is: 'scroll-link',
properties: {
href: String,
title: String,
top: {
type: Number,
value: 0
},
left: {
type: Number,
value: 0
},
},
listeners: {
'tap': 'scroll',
},
scroll: function(event) {
event.preventDefault();
if (this.href) {
return document.querySelector(this.href).scrollIntoView({ behavior: 'smooth' });
}
return window.scrollTo({ top: this.top, left: this.left, behavior: 'smooth' });
}
});
</script>
</dom-module>