Skip to content

Commit 03ae94a

Browse files
committed
demo added - edge hover bug fix - scroll threshold altered
1 parent 827a0a1 commit 03ae94a

File tree

7 files changed

+201
-3
lines changed

7 files changed

+201
-3
lines changed

Demo/easyScrollDotsDemo.html

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<!-- https://github.com/Superhands89/EasyScrollDots -->
2+
<!DOCTYPE HTML>
3+
<html>
4+
<head>
5+
<title>Easy Scroll Dots</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<!--test template style-->
8+
<style>html{height:100%}*{margin:0;padding:0}body{font:normal 15px 'trebuchet ms',arial,sans-serif;background:#FFF url(background.png) repeat;color:#777;word-break:break-all}p{padding:0 0 20px 0;line-height:1.7em}img{border:0}h1,h2,h3,h4,h5,h6{font:bold 28px 'century gothic',arial,sans-serif;color:#068900;margin:0 0 15px 0;padding:15px 0 5px 0}h2{font:normal 115% 'century gothic',arial,sans-serif;color:#068900}h4,h5,h6{margin:0;padding:0 0 5px 0;font:normal 25px arial,sans-serif;color:#068900}h5,h6{font:italic 21px arial,sans-serif;padding:0 0 15px 0;color:#000}h6{color:#362C20}a,a:hover{outline:none;text-decoration:underline;color:tomato}a:hover{text-decoration:none}.left{float:left;width:auto;margin-right:10px}.right{float:right;width:auto;margin-left:10px}.center{display:block;text-align:center;margin:20px auto}blockquote{margin:20px 0;padding:10px 20px 0 20px;border:1px solid #E5E5DB;background:#FFF}ul{margin:2px 0 22px 17px}ul li{list-style-type:circle;margin:0 0 6px 0;padding:0 0 4px 5px}ol{margin:8px 0 22px 20px}ol li{margin:0 0 11px 0}#main,#logo,#menubar,#site_content,#footer{margin-left:auto;margin-right:auto}#header{height:240px}#logo{width:80%;position:relative;margin-bottom:45px}#logo h1,#logo h2{font:normal 300% 'century gothic',arial,sans-serif;border-bottom:0;text-transform:none;margin:0}#logo_text h1,#logo_text h1 a,#logo_text h1 a:hover{padding:22px 0 0 0;color:#000;letter-spacing:.1em;text-decoration:none}#logo_text h1 a .logo_colour{color:#068900}#logo_text h2{font-size:15px;padding:4px 0 0 0;color:#676767}#menubar{width:80%;height:72px;padding:0;background:transparent url(transparent.png) repeat}ul#menu,ul#menu li{float:left;margin:0;padding:0}ul#menu li{list-style:none}ul#menu li a{letter-spacing:.1em;font:normal 15px arial,sans-serif;display:block;float:left;height:37px;padding:29px 26px 6px 26px;text-align:center;color:#000;text-transform:uppercase;text-decoration:none;border-bottom:2px solid #068900;background:transparent}ul#menu li a:hover,ul#menu li.selected a,ul#menu li.selected a:hover{color:#FFF;background:#068900}#site_content{width:80%;overflow:hidden;margin:0 auto 0 auto;padding:20px 20px 20px 20px;background:transparent url(transparent_light.png) repeat}.sidebar{float:right;width:190px;padding:0 15px 20px 15px}.sidebar ul{width:178px;padding:4px 0 0 0;margin:4px 0 30px 0}.sidebar li{list-style:none;padding:0 0 7px 0}.sidebar li a,.sidebar li a:hover{padding:0 0 0 40px;display:block;background:transparent url(link.png) no-repeat left center}.sidebar li a.selected{color:#444;text-decoration:none}#content{text-align:left;padding:0}#content ul{margin:2px 0 22px 0}#content ul li{list-style-type:none;background:url(bullet.png) no-repeat;margin:0 0 6px 0;padding:0 0 4px 25px;line-height:1.5em}#footer{width:900px;font:normal 15px 'lucida sans unicode',arial,sans-serif;height:33px;padding:24px 0 5px 0;text-align:center;background:transparent url(transparent.png) repeat;color:#FFF;text-transform:uppercase;letter-spacing:.1em}#footer a{color:#FFF;text-decoration:none}#footer a:hover{color:#FFF;text-decoration:underline}footer{background:#068900;height:350px}footer h2{color:#fff;font-size:28px;width:80%;margin:auto}.search{color:#5D5D5D;border:1px solid #BBB;width:134px;padding:4px;font:100% arial,sans-serif}#colours{height:0;text-align:right;padding:66px 16px 0 300px}.form_settings{margin:15px 0 0 0}.form_settings p{padding:0 0 4px 0}.form_settings span{float:left;width:200px;text-align:left}.form_settings input,.form_settings textarea{padding:5px;width:299px;font:15px arial;border:1px solid #E5E5DB;background:#FFF;color:#47433F}.form_settings .submit{font:15px arial;border:1px solid;width:99px;margin:0 0 0 212px;height:33px;padding:2px 0 3px 0;cursor:pointer;background:#068900;color:#FFF}.form_settings textarea,.form_settings select{font:15px arial;width:299px}.form_settings select{width:310px}.form_settings .checkbox{margin:4px 0;padding:0;width:14px;border:0;background:none}.separator{width:100%;height:0;border-top:1px solid #D9D5CF;border-bottom:1px solid #FFF;margin:0 0 20px 0}table{margin:10px 0 30px 0}table tr th,table tr td{background:#3B3B3B;color:#FFF;padding:7px 4px;text-align:left}table tr td{background:#F0EFE2;color:#47433F;border-top:1px solid #FFF}</style>
9+
<!--Easy Scroll Dots style-->
10+
<style>.scroll-indicator-controller{position:fixed;top:50%;transform:translate(0,-50%);right:20px;z-index:2}.scroll-indicator-controller.indi-mobile>div span{display:none}@media (max-width:1024px){.scroll-indicator-controller{right:10px}}.scroll-indicator-controller>div{width:20px;height:20px;position:relative;border-radius:50%;border:1px solid tomato;background:rgba(0,0,0,.25);margin:0 0 10px;cursor:pointer;transition:background .4s ease;will-change:transition}.scroll-indicator-controller>div span{color:tomato;position:absolute;right:calc(100% + 8px);white-space:nowrap;top:-1px;font-family:arial,sans-serif;font-size:16px;line-height:17px;width:0;overflow:hidden;opacity:0;transform:translateX(10px);transition:all .4s ease;will-change:transition}@media (hover:none){.scroll-indicator-controller>div span{display:none}}.scroll-indicator-controller>div span:after{content:"-----";padding-left:5px;letter-spacing:-2px;font-family:arial,sans-serif;vertical-align:text-top}@media (hover:hover),(-ms-high-contrast:none),(-ms-high-contrast:active){.scroll-indicator-controller>div:hover span{width:auto;opacity:1;overflow:visible;transform:translateX(0)}}.scroll-indicator-controller>div.active{background:tomato;border-color:rgba(0,0,0,.25)}@supports (-ms-ime-align:auto){.scroll-indicator-controller>div span{transition:opacity .4s ease}}</style>
11+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
12+
</head>
13+
<body>
14+
<div id="main">
15+
<div id="header">
16+
<div id="logo">
17+
<div id="logo_text">
18+
<h1><a href="index.html">Easy<span class="logo_colour">Scroll</span></a>Dots - Demo</h1>
19+
<h2>Check it out at:
20+
<a href="https://github.com/Superhands89/EasyScrollDots" target="_blank">
21+
https://github.com/Superhands89/EasyScrollDots
22+
</a></h2>
23+
</div>
24+
</div>
25+
<div id="menubar">
26+
<ul id="menu">
27+
<li class="selected"><a href="#">Home</a></li>
28+
<li><a href="#">Examples</a></li>
29+
<li><a href="#">A Page</a></li>
30+
<li><a href="#">Another Page</a></li>
31+
<li><a href="#">Contact Us</a></li>
32+
</ul>
33+
</div>
34+
</div>
35+
<div id="site_content">
36+
<div id="content">
37+
38+
<!-- HERE'S AN ANCHOR POINT (SCROLL INDICATOR) -->
39+
<div>
40+
<div class="scroll-indicator" id="section01" data-scroll-indicator-title="First Section"></div>
41+
</div>
42+
43+
<div>
44+
<h1>Welcome to section 1</h1>
45+
<p>This standards compliant, simple, fixed width website template is released as an 'open source' design (under Creative Commons Attribution 3.0 Licence), which means that you are free to download and use it for anything you want (including modifying and amending it). All I ask is that you leave the 'design from HTML5webtemplates.co.uk' link in the footer of the template, but other than that...</p>
46+
<p>This template is written entirely in <strong>HTML5</strong> and <strong>CSS</strong>, and can be validated using the links in the footer.</p>
47+
<p>You can view more free HTML5 web templates.</p>
48+
<p>This template is a fully functional 5 page website, with an page that gives examples of all the styles available with this design.</p>
49+
<h2>Lorem ipsum dolor</h2>
50+
<p>This template is a fully functional 5 page website, with an page that gives examples of all the styles available with this design.</p>
51+
<p>This template is a fully functional 5 page website, with an page that gives examples of all the styles available with this design.</p>
52+
<p>This template is a fully functional 5 page website, with an page that gives examples of all the styles available with this design.</p>
53+
<p>This template is a fully functional 5 page website, with an page that gives examples of all the styles available with this design.</p>
54+
</div>
55+
56+
<!-- HERE'S AN ANCHOR POINT (SCROLL INDICATOR) -->
57+
<div>
58+
<div class="scroll-indicator" id="section02" data-scroll-indicator-title="Another Section"></div>
59+
</div>
60+
61+
<div>
62+
<h1>Welcome to section 2</h1>
63+
<p>This standards compliant, simple, fixed width website template is released as an 'open source' design (under Creative Commons Attribution 3.0 Licence), which means that you are free to download and use it for anything you want (including modifying and amending it). All I ask is that you leave the 'design from HTML5webtemplates.co.uk' link in the footer of the template, but other than that...</p>
64+
<p>This template is written entirely in <strong>HTML5</strong> and <strong>CSS</strong>, and can be validated using the links in the footer.</p>
65+
<p>You can view more free HTML5 web templates.</p>
66+
<p>This template is a fully functional 5 page website, with an page that gives examples of all the styles available with this design.</p>
67+
<h2>Lorem ipsum dolor</h2>
68+
<p>This template is a fully functional 5 page website, with an page that gives examples of all the styles available with this design.</p>
69+
<p>This template is a fully functional 5 page website, with an page that gives examples of all the styles available with this design.</p>
70+
<p>This template is a fully functional 5 page website, with an page that gives examples of all the styles available with this design.</p>
71+
<p>This template is a fully functional 5 page website, with an page that gives examples of all the styles available with this design.</p>
72+
</div>
73+
74+
<!-- HERE'S AN ANCHOR POINT (SCROLL INDICATOR) -->
75+
<div>
76+
<div class="scroll-indicator" id="section03" data-scroll-indicator-title="Hello World"></div>
77+
</div>
78+
79+
<div>
80+
<h1>Welcome to section 3 - Hello world</h1>
81+
<p>This standards compliant, simple, fixed width website template is released as an 'open source' design (under Creative Commons Attribution 3.0 Licence), which means that you are free to download and use it for anything you want (including modifying and amending it). All I ask is that you leave the 'design from HTML5webtemplates.co.uk' link in the footer of the template, but other than that...</p>
82+
<p>This template is written entirely in <strong>HTML5</strong> and <strong>CSS</strong>, and can be validated using the links in the footer.</p>
83+
<p>You can view more free HTML5 web templates.</p>
84+
<p>This template is a fully functional 5 page website, with an page that gives examples of all the styles available with this design.</p>
85+
<h2>Lorem ipsum dolor</h2>
86+
<p>This template is a fully functional 5 page website, with an page that gives examples of all the styles available with this design.</p>
87+
<p>This template is a fully functional 5 page website, with an page that gives examples of all the styles available with this design.</p>
88+
<p>This template is a fully functional 5 page website, with an page that gives examples of all the styles available with this design.</p>
89+
<p>This template is a fully functional 5 page website, with an page that gives examples of all the styles available with this design.</p>
90+
</div>
91+
</div>
92+
</div>
93+
</div>
94+
<footer><h2>Footer</h2></footer>
95+
<!--Easy Scroll Dots js-->
96+
<script>function dotsThrottle(a,b,c){var d,e,f,g=null,h=0;c||(c={});var i=function(){h=!1===c.leading?0:Date.now(),g=null,f=a.apply(d,e),g||(d=e=null)};return function(){var j=Date.now();h||!1!==c.leading||(h=j);var k=b-(j-h);return d=this,e=arguments,0>=k||k>b?(g&&(clearTimeout(g),g=null),h=j,f=a.apply(d,e),!g&&(d=e=null)):!g&&!1!==c.trailing&&(g=setTimeout(i,k)),f}}let dotFixedNavPresent=!1,dotFixedNavId="",dotFixedNavUp=!1;function easyScrollDots(a){let b=document.querySelectorAll(".scroll-indicator");if(!0===a.fixedNav?dotFixedNavPresent=!0:dotFixedNavPresent,dotFixedNavId=""!==a.fixedNavId&&a.fixedNavId,!0===a.fixedNavUpward?dotFixedNavUp=!0:dotFixedNavUp,b.length){document.querySelector("body").lastElementChild.insertAdjacentHTML("afterend","<div class=\"scroll-indicator-controller\"><span></span></div>");const a=document.querySelector(".scroll-indicator-controller");("undefined"!=typeof window.orientation||-1!==navigator.userAgent.indexOf("IEMobile"))&&a.classList.add("indi-mobile");const d=Array.prototype.slice.call(b);d.forEach(function(b,c){const d=b.getAttribute("id"),e=b.getAttribute("data-scroll-indicator-title");let f="";0==c&&(f="active"),a.lastElementChild.insertAdjacentHTML("afterend","<div class=\""+f+"\" data-indi-controller-id=\""+d+"\" onclick=\"scrollIndiClicked('"+d+"');\"><span>"+e+"</span><div></div></div>")});const f=a.querySelectorAll("[data-indi-controller-id]");var c=dotsThrottle(function(){let b={};d.forEach(function(a){const c=a.getAttribute("id"),d=a.getBoundingClientRect().top;b[c]=d});const c=Object.keys(b).map(function(a){return b[a]}),g=function(){const a=c.filter(function(a){return-150<a});return Math.min.apply(null,a)};Object.keys(b).forEach(function(c){b[c]==g()&&(Array.prototype.forEach.call(f,function(a){a.classList.contains("active")&&a.classList.remove("active")}),a.querySelector("[data-indi-controller-id=\""+c+"\"]").classList.add("active"))})},300);window.onscroll=function(){c()}}}function scrollIndiClicked(a){if(window.jQuery){if(!0==dotFixedNavPresent&&dotFixedNavId.length){const b=document.getElementById(dotFixedNavId),c=b.clientHeight,d=$("html, body"),e=$("#"+a);if(!0===dotFixedNavUp){d.animate({scrollTop:e.offset().top},700);const a=document.body.getBoundingClientRect().top;setTimeout(function(){document.body.getBoundingClientRect().top>a&&d.animate({scrollTop:e.offset().top-c},400)},400)}else d.animate({scrollTop:e.offset().top-c},700)}else $("html, body").animate({scrollTop:$("#"+a).offset().top},700);}else if(!0==dotFixedNavPresent&&dotFixedNavId.length){const b=document.getElementById(dotFixedNavId),c=b.clientHeight,d=document.getElementById(a);if(!0===dotFixedNavUp){window.scrollTo({top:d.offsetTop,left:0,behavior:"smooth"});const a=document.body.getBoundingClientRect().top;setTimeout(function(){document.body.getBoundingClientRect().top>a&&window.scrollTo({top:d.offsetTop-c,left:0,behavior:"smooth"})},400)}else window.scrollTo({top:d.offsetTop-c,left:0,behavior:"smooth"})}else window.scrollTo({top:document.getElementById(a).offsetTop,left:0,behavior:"smooth"})}</script>
97+
<!--Easy Scroll Dots init-->
98+
<script>
99+
easyScrollDots({
100+
'fixedNav': false,
101+
'fixedNavId': '',
102+
'fixedNavUpward': false
103+
});
104+
</script>
105+
</body>
106+
</html>

dist/LESS/easyScrollDots.css

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/* Easy Scroll Dots 1.0.8 --- https://github.com/Superhands89/EasyScrollDots
2+
* Quickly add anchor points throughout your web page/application and have navigational dots automatically appear
3+
* in a fixed position on the side of the page. This allows the user to click to scroll though sections of the page,
4+
* and it updates as they scroll.
5+
*
6+
* By Paul Dolby (Superhands89) 2019 --- https://github.com/Superhands89/
7+
*
8+
* MIT Licence - Free and unrestricted use.
9+
*/
10+
.scroll-indicator-controller {
11+
position: fixed;
12+
top: 50%;
13+
transform: translate(0, -50%);
14+
right: 20px;
15+
z-index: 2;
16+
}
17+
.scroll-indicator-controller.indi-mobile > div span {
18+
display: none;
19+
}
20+
@media (max-width: 1024px) {
21+
.scroll-indicator-controller {
22+
right: 10px;
23+
}
24+
}
25+
.scroll-indicator-controller > div {
26+
width: 20px;
27+
height: 20px;
28+
position: relative;
29+
border-radius: 50%;
30+
border: 1px solid tomato;
31+
background: rgba(0, 0, 0, 0.25);
32+
margin: 0 0 10px 0;
33+
cursor: pointer;
34+
transition: background 0.4s ease;
35+
will-change: transition;
36+
}
37+
.scroll-indicator-controller > div span {
38+
color: tomato;
39+
position: absolute;
40+
right: calc(100% + 8px);
41+
white-space: nowrap;
42+
top: -1px;
43+
font-family: arial, sans-serif;
44+
font-size: 16px;
45+
line-height: 17px;
46+
width: 0;
47+
overflow: hidden;
48+
opacity: 0;
49+
transform: translateX(10px);
50+
transition: all 0.4s ease;
51+
will-change: transition;
52+
}
53+
@media (hover: none) {
54+
.scroll-indicator-controller > div span {
55+
display: none;
56+
}
57+
}
58+
.scroll-indicator-controller > div span:after {
59+
content: "-----";
60+
padding-left: 5px;
61+
letter-spacing: -2px;
62+
font-family: arial, sans-serif;
63+
vertical-align: text-top;
64+
}
65+
@media (hover: hover), (-ms-high-contrast: none), (-ms-high-contrast: active) {
66+
.scroll-indicator-controller > div:hover span {
67+
width: auto;
68+
opacity: 1;
69+
overflow: visible;
70+
transform: translateX(0px);
71+
}
72+
}
73+
.scroll-indicator-controller > div.active {
74+
background: tomato;
75+
border-color: rgba(0, 0, 0, 0.25);
76+
}
77+
@supports (-ms-ime-align:auto) {
78+
.scroll-indicator-controller > div span {
79+
transition: opacity 0.4s ease;
80+
}
81+
}

dist/LESS/easyScrollDots.less

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,9 @@
8181
}
8282
}
8383
}
84+
//edge
85+
@supports (-ms-ime-align:auto) {
86+
.scroll-indicator-controller > div span {
87+
transition: opacity 0.4s ease;
88+
}
89+
}

dist/easyScrollDots.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,8 @@
7474
background: tomato;
7575
border-color: rgba(0, 0, 0, 0.25);
7676
}
77+
@supports (-ms-ime-align:auto) {
78+
.scroll-indicator-controller > div span {
79+
transition: opacity 0.4s ease;
80+
}
81+
}

dist/easyScrollDots.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function easyScrollDots(dotfixedOptions) {
8686
// const indiOffsetValues = Object.values(indiScrollTopCollection); not supported in IE
8787
const indiOffsetValues = Object.keys(indiScrollTopCollection).map(function (itm) { return indiScrollTopCollection[itm]; });
8888
const indiOffsetMin = function () {
89-
const indiRemoveMinuses = indiOffsetValues.filter(function (x) { return x > -1; });
89+
const indiRemoveMinuses = indiOffsetValues.filter(function (x) { return x > -150; });
9090

9191
return Math.min.apply(null, indiRemoveMinuses);
9292
};

0 commit comments

Comments
 (0)