@internetstiftelsen/styleguide 2.22.4 → 2.22.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/js/anchorScroll.js +16 -0
- package/dist/assets/js/offset.js +26 -0
- package/dist/assets/js/parallax.js +17 -0
- package/dist/assets/js/youtube.js +38 -9
- package/dist/components.js +2 -0
- package/dist/molecules/continue-video-guide/continue-video-guide.js +91 -0
- package/dist/molecules/glider/glider-course.js +7 -7
- package/dist/molecules/glider/glider-hero.js +47 -0
- package/dist/organisms/timeline/timeline.js +155 -0
- package/dist/organisms/video-guide/video-guide.js +312 -0
- package/package.json +8 -6
- package/src/.DS_Store +0 -0
- package/src/app.scss +3 -2
- package/src/assets/js/anchorScroll.js +10 -0
- package/src/assets/js/offset.js +22 -0
- package/src/assets/js/parallax.js +15 -0
- package/src/assets/js/youtube.js +34 -9
- package/src/assets/video/Internets-Historia-HEVC-h265-HEVC-h265.mov +0 -0
- package/src/assets/video/Internets-Historia-HEVC-h265-vp9-chrome.webm +0 -0
- package/src/assets/video/chapters.vtt +25 -0
- package/src/assets/video/metadata.vtt +28 -0
- package/src/assets/video/movie-webm.webm +0 -0
- package/src/assets/video/videoplayer.vtt +25 -0
- package/src/atoms/button/_button.scss +6 -9
- package/src/atoms/icon/_all-icons.zip +0 -0
- package/src/atoms/icon/spinner-white.svg +1 -9
- package/src/atoms/icon/spinner.svg +1 -9
- package/src/atoms/icon/sprite.svg +17 -0
- package/src/atoms/icon/step-backwards.svg +1 -0
- package/src/atoms/icon/step-forwards.svg +1 -0
- package/src/atoms/icon/subtitles.svg +1 -0
- package/src/atoms/meta/meta.config.js +1 -1
- package/src/atoms/tag/_tag.scss +2 -2
- package/src/base/_normalize.scss +1 -1
- package/src/base/fonts/_fonts.scss +8 -8
- package/src/brandbook/.DS_Store +0 -0
- package/src/components.js +1 -0
- package/src/configurations/_extends.scss +5 -1
- package/src/configurations/_variables.scss +3 -3
- package/src/configurations/_wordpress.scss +9 -0
- package/src/configurations/colors/_colors-functions.scss +2 -3
- package/src/configurations/grid/_grid.scss +26 -7
- package/src/configurations/icons.json +1 -1
- package/src/configurations/typography/_typography.scss +61 -7
- package/src/molecules/glider/_glider-course.scss +121 -0
- package/src/molecules/glider/_glider-hero.scss +327 -0
- package/src/molecules/glider/_glider.scss +3 -116
- package/src/molecules/glider/glider-course.js +7 -7
- package/src/molecules/glider/glider-hero.js +41 -0
- package/src/molecules/glider/glider.config.js +7 -0
- package/src/organisms/hero/_hero--dynamic-headline.scss +168 -0
- package/src/organisms/hero/_hero.scss +16 -0
- package/src/organisms/hero/hero.config.js +10 -1
- package/src/structures/_article.scss +4 -6
- package/src/utilities/_hide.scss +4 -0
- package/src/utilities/_links.scss +11 -0
- package/src/assets/css/footer/isolated-footer.css +0 -7367
- package/src/assets/css/footer/isolated-footer.css.map +0 -1
- package/src/assets/css/footer/isolated-footer.min.css +0 -2
- package/src/pages/timeline/timeline.config.js +0 -19
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _smoothScroll = require('smooth-scroll');
|
|
4
|
+
|
|
5
|
+
var _smoothScroll2 = _interopRequireDefault(_smoothScroll);
|
|
6
|
+
|
|
7
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
+
|
|
9
|
+
var anchorScroll = new _smoothScroll2.default('a[href*="#"]', {
|
|
10
|
+
speed: 1500,
|
|
11
|
+
speedAsDuration: true,
|
|
12
|
+
easing: 'easeOutCubic',
|
|
13
|
+
ignore: '[data-scroll-ignore]'
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
module.exports = anchorScroll;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
// Get top of element relative to window
|
|
5
|
+
offsetTop: function offsetTop(el) {
|
|
6
|
+
var rect = el.getBoundingClientRect();
|
|
7
|
+
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
8
|
+
return rect.top + scrollTop;
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
// Get bottom of element relative to window
|
|
13
|
+
offsetBottom: function offsetBottom(el) {
|
|
14
|
+
var rect = el.getBoundingClientRect();
|
|
15
|
+
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
16
|
+
return rect.bottom + scrollTop;
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
// Get left of element relative to window
|
|
21
|
+
offsetLeft: function offsetLeft(el) {
|
|
22
|
+
var rect = el.getBoundingClientRect();
|
|
23
|
+
var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
|
24
|
+
return rect.left + scrollLeft;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function isInView(el) {
|
|
4
|
+
var box = el.getBoundingClientRect();
|
|
5
|
+
return box.top < window.innerHeight && box.bottom >= 0;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
var parallaxes = document.querySelectorAll('.js-parallax');
|
|
9
|
+
|
|
10
|
+
window.addEventListener('scroll', function () {
|
|
11
|
+
[].forEach.call(parallaxes, function (parallax) {
|
|
12
|
+
var visible = isInView(parallax);
|
|
13
|
+
if (visible) {
|
|
14
|
+
parallax.classList.add('animate');
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setupPlayers = setupPlayers;
|
|
3
7
|
function loadYoutubeAPI() {
|
|
4
8
|
var tag = document.createElement('script');
|
|
5
9
|
var firstScript = document.getElementsByTagName('script')[0];
|
|
@@ -9,10 +13,8 @@ function loadYoutubeAPI() {
|
|
|
9
13
|
firstScript.parentNode.insertBefore(tag, firstScript);
|
|
10
14
|
}
|
|
11
15
|
|
|
12
|
-
function onPlayerReady(el
|
|
13
|
-
el.
|
|
14
|
-
e.target.playVideo();
|
|
15
|
-
});
|
|
16
|
+
function onPlayerReady(el) {
|
|
17
|
+
el.setAttribute('data-youtube-ready', 'true');
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
function onPlayerStateChange(el, e) {
|
|
@@ -32,16 +34,28 @@ function createCover(el, id) {
|
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
function setupYoutubePlayer(el) {
|
|
35
|
-
var playerEl =
|
|
37
|
+
var playerEl = void 0;
|
|
36
38
|
var id = el.getAttribute('data-youtube');
|
|
37
39
|
|
|
40
|
+
if (el.youtube) {
|
|
41
|
+
playerEl = el.querySelector('[data-youtube-container]');
|
|
42
|
+
|
|
43
|
+
playerEl.parentNode.removeChild(playerEl);
|
|
44
|
+
el.youtube.destroy();
|
|
45
|
+
el.youtube = null;
|
|
46
|
+
el.removeAttribute('data-youtube-ready');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
playerEl = document.createElement('div');
|
|
50
|
+
|
|
38
51
|
if (!el.getElementsByTagName('img').length) {
|
|
39
52
|
createCover(el, id);
|
|
40
53
|
}
|
|
41
54
|
|
|
55
|
+
playerEl.setAttribute('data-youtube-container', true);
|
|
42
56
|
el.appendChild(playerEl);
|
|
43
57
|
|
|
44
|
-
|
|
58
|
+
el.youtube = new YT.Player(playerEl, {
|
|
45
59
|
height: '100%',
|
|
46
60
|
width: '100%',
|
|
47
61
|
videoId: id,
|
|
@@ -59,18 +73,33 @@ function setupYoutubePlayer(el) {
|
|
|
59
73
|
}
|
|
60
74
|
}
|
|
61
75
|
});
|
|
76
|
+
}
|
|
62
77
|
|
|
63
|
-
|
|
78
|
+
function delegateClick(e) {
|
|
79
|
+
var el = e.target.closest('[data-youtube]');
|
|
80
|
+
|
|
81
|
+
if (!el || !el.youtube) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
el.youtube.playVideo();
|
|
64
86
|
}
|
|
65
87
|
|
|
66
|
-
|
|
67
|
-
|
|
88
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
89
|
+
function setupPlayers(container) {
|
|
90
|
+
var players = container.querySelectorAll('[data-youtube]');
|
|
68
91
|
|
|
69
92
|
if (!players.length) {
|
|
70
93
|
return;
|
|
71
94
|
}
|
|
72
95
|
|
|
73
96
|
[].forEach.call(players, setupYoutubePlayer);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
window.onYouTubeIframeAPIReady = function () {
|
|
100
|
+
setupPlayers(document);
|
|
101
|
+
|
|
102
|
+
document.body.addEventListener('click', delegateClick);
|
|
74
103
|
};
|
|
75
104
|
|
|
76
105
|
loadYoutubeAPI();
|
package/dist/components.js
CHANGED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
4
|
+
|
|
5
|
+
var _className = require('../../assets/js/className');
|
|
6
|
+
|
|
7
|
+
var _className2 = _interopRequireDefault(_className);
|
|
8
|
+
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
|
|
11
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
+
|
|
13
|
+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
14
|
+
|
|
15
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
16
|
+
|
|
17
|
+
function _CustomElement() {
|
|
18
|
+
return Reflect.construct(HTMLElement, [], this.__proto__.constructor);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
;
|
|
22
|
+
Object.setPrototypeOf(_CustomElement.prototype, HTMLElement.prototype);
|
|
23
|
+
Object.setPrototypeOf(_CustomElement, HTMLElement);
|
|
24
|
+
|
|
25
|
+
var ProgressRing = function (_CustomElement2) {
|
|
26
|
+
_inherits(ProgressRing, _CustomElement2);
|
|
27
|
+
|
|
28
|
+
function ProgressRing() {
|
|
29
|
+
_classCallCheck(this, ProgressRing);
|
|
30
|
+
|
|
31
|
+
var _this = _possibleConstructorReturn(this, (ProgressRing.__proto__ || Object.getPrototypeOf(ProgressRing)).call(this));
|
|
32
|
+
|
|
33
|
+
var stroke = _this.getAttribute('stroke');
|
|
34
|
+
var radius = _this.getAttribute('radius');
|
|
35
|
+
var normalizedRadius = radius - stroke * 2;
|
|
36
|
+
_this.circumference = normalizedRadius * 2 * Math.PI;
|
|
37
|
+
|
|
38
|
+
_this.root = _this.attachShadow({ mode: 'open' });
|
|
39
|
+
_this.root.innerHTML = '\n\t\t<svg\n\t\theight="' + radius * 2 + '"\n\t\twidth="' + radius * 2 + '"\n\t\t>\n\t\t<circle\n\t\tstroke="white"\n\t\tstroke-dasharray="' + _this.circumference + ' ' + _this.circumference + '"\n\t\tstyle="stroke-dashoffset:' + _this.circumference + '"\n\t\tstroke-width="' + stroke + '"\n\t\tfill="transparent"\n\t\tr="' + normalizedRadius + '"\n\t\tcx="' + radius + '"\n\t\tcy="' + radius + '"\n\t\t/>\n\t\t</svg>\n\n\t\t<style>\n\t\tcircle {\n\t\t\ttransition: stroke-dashoffset 0.35s;\n\t\t\ttransform: rotate(-90deg);\n\t\t\ttransform-origin: 50% 50%;\n\t\t}\n\t\t</style>\n\t\t';
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
_createClass(ProgressRing, [{
|
|
44
|
+
key: 'setProgress',
|
|
45
|
+
value: function setProgress(percent) {
|
|
46
|
+
var offset = this.circumference - percent / 100 * this.circumference;
|
|
47
|
+
var circle = this.root.querySelector('circle');
|
|
48
|
+
circle.style.strokeDashoffset = offset;
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
key: 'attributeChangedCallback',
|
|
52
|
+
value: function attributeChangedCallback(name, oldValue, newValue) {
|
|
53
|
+
if (name === 'progress') {
|
|
54
|
+
this.setProgress(newValue);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}], [{
|
|
58
|
+
key: 'observedAttributes',
|
|
59
|
+
get: function get() {
|
|
60
|
+
return ['progress'];
|
|
61
|
+
}
|
|
62
|
+
}]);
|
|
63
|
+
|
|
64
|
+
return ProgressRing;
|
|
65
|
+
}(_CustomElement);
|
|
66
|
+
|
|
67
|
+
window.customElements.define('progress-ring', ProgressRing);
|
|
68
|
+
|
|
69
|
+
// Get value from localStorage if present
|
|
70
|
+
if (localStorage.getItem('InmsCurrentTime')) {
|
|
71
|
+
var videoCurrentTime = localStorage.getItem('InmsCurrentTime');
|
|
72
|
+
var videoDuration = localStorage.getItem('InmsDuration');
|
|
73
|
+
var continueElement = document.querySelector('.js-guide-continue');
|
|
74
|
+
var progressRing = document.querySelector('progress-ring');
|
|
75
|
+
var continueLink = document.querySelector('.js-guide-continue-link');
|
|
76
|
+
var guideURL = localStorage.getItem('InmsCurrentGuideURL');
|
|
77
|
+
var guideImage = localStorage.getItem('InmsCurrentGuideImage');
|
|
78
|
+
|
|
79
|
+
if (videoCurrentTime > 0 && progressRing && continueElement && guideImage && continueLink) {
|
|
80
|
+
var alternativeText = continueLink.dataset.altText;
|
|
81
|
+
var currentProgress = videoCurrentTime / videoDuration;
|
|
82
|
+
var currentGuideImage = document.querySelector('.js-guide-continue-image');
|
|
83
|
+
|
|
84
|
+
continueElement.classList.add((0, _className2.default)('m-continue-video-guide--has-progress'));
|
|
85
|
+
continueLink.setAttribute('href', guideURL);
|
|
86
|
+
currentGuideImage.src = guideImage;
|
|
87
|
+
continueLink.querySelector('span').innerText = alternativeText;
|
|
88
|
+
// Calculate percentage played
|
|
89
|
+
progressRing.setAttribute('progress', Math.floor(currentProgress * 100));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -6,10 +6,10 @@ var _gliderJs2 = _interopRequireDefault(_gliderJs);
|
|
|
6
6
|
|
|
7
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var gliderElementCourse = document.querySelector('.js-glider-course');
|
|
10
10
|
|
|
11
|
-
if (
|
|
12
|
-
var
|
|
11
|
+
if (gliderElementCourse) {
|
|
12
|
+
var GliderCourse = new _gliderJs2.default(gliderElementCourse, {
|
|
13
13
|
scrollLock: true,
|
|
14
14
|
slidesToShow: 1,
|
|
15
15
|
slidesToScroll: 1
|
|
@@ -19,7 +19,7 @@ if (gliderElementSingle) {
|
|
|
19
19
|
var prevBtns = document.querySelectorAll('.js-glider-prev');
|
|
20
20
|
var siteMain = document.querySelector('#siteMain');
|
|
21
21
|
var zoomImages = document.querySelectorAll('.js-zoom.zoom');
|
|
22
|
-
var slideIndex =
|
|
22
|
+
var slideIndex = GliderCourse.getCurrentSlide();
|
|
23
23
|
var bounding = 0;
|
|
24
24
|
|
|
25
25
|
var scrollTop = function scrollTop() {
|
|
@@ -29,7 +29,7 @@ if (gliderElementSingle) {
|
|
|
29
29
|
if (nextBtns) {
|
|
30
30
|
[].forEach.call(nextBtns, function (nextBtn) {
|
|
31
31
|
nextBtn.addEventListener('click', function () {
|
|
32
|
-
|
|
32
|
+
GliderCourse.scrollItem(slideIndex += 1, true);
|
|
33
33
|
|
|
34
34
|
if (siteMain) {
|
|
35
35
|
bounding = siteMain.getBoundingClientRect();
|
|
@@ -44,7 +44,7 @@ if (gliderElementSingle) {
|
|
|
44
44
|
if (prevBtns) {
|
|
45
45
|
[].forEach.call(prevBtns, function (prevBtn) {
|
|
46
46
|
prevBtn.addEventListener('click', function () {
|
|
47
|
-
|
|
47
|
+
GliderCourse.scrollItem(slideIndex -= 1, true);
|
|
48
48
|
|
|
49
49
|
if (siteMain) {
|
|
50
50
|
bounding = siteMain.getBoundingClientRect();
|
|
@@ -64,5 +64,5 @@ if (gliderElementSingle) {
|
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
module.exports =
|
|
67
|
+
module.exports = GliderCourse;
|
|
68
68
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _gliderJs = require('glider-js');
|
|
4
|
+
|
|
5
|
+
var _gliderJs2 = _interopRequireDefault(_gliderJs);
|
|
6
|
+
|
|
7
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
+
|
|
9
|
+
var gliderElementHero = document.querySelector('.js-glider-hero');
|
|
10
|
+
|
|
11
|
+
if (gliderElementHero) {
|
|
12
|
+
var GliderHero = new _gliderJs2.default(gliderElementHero, {
|
|
13
|
+
scrollLock: true,
|
|
14
|
+
slidesToShow: 1,
|
|
15
|
+
slidesToScroll: 1,
|
|
16
|
+
rewind: true,
|
|
17
|
+
arrows: {
|
|
18
|
+
prev: '.js-glider-prev',
|
|
19
|
+
next: '.js-glider-next'
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
var autoplayDelay = gliderElementHero.dataset.timeout;
|
|
24
|
+
|
|
25
|
+
if (autoplayDelay) {
|
|
26
|
+
var autoplay = setInterval(function () {
|
|
27
|
+
GliderHero.scrollItem('next');
|
|
28
|
+
}, autoplayDelay);
|
|
29
|
+
|
|
30
|
+
gliderElementHero.addEventListener('mouseover', function () {
|
|
31
|
+
if (autoplay !== null) {
|
|
32
|
+
clearInterval(autoplay);
|
|
33
|
+
autoplay = null;
|
|
34
|
+
}
|
|
35
|
+
}, 0);
|
|
36
|
+
|
|
37
|
+
gliderElementHero.addEventListener('mouseout', function () {
|
|
38
|
+
if (autoplay === null) {
|
|
39
|
+
autoplay = setInterval(function () {
|
|
40
|
+
GliderHero.scrollItem('next');
|
|
41
|
+
}, autoplayDelay);
|
|
42
|
+
}
|
|
43
|
+
}, 0);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = GliderHero;
|
|
47
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../../assets/js/parallax');
|
|
4
|
+
|
|
5
|
+
var _require = require('../../assets/js/offset'),
|
|
6
|
+
offsetTop = _require.offsetTop,
|
|
7
|
+
offsetBottom = _require.offsetBottom,
|
|
8
|
+
offsetLeft = _require.offsetLeft;
|
|
9
|
+
|
|
10
|
+
var progressBar = document.querySelector('.js-progress-bar');
|
|
11
|
+
var decadeContainer = document.querySelector('.js-decade-container');
|
|
12
|
+
var decadeSections = document.querySelectorAll('.js-timeline-decade');
|
|
13
|
+
var firstDecade = document.querySelector('h2.godzilla');
|
|
14
|
+
var decades = document.querySelectorAll('h2.godzilla');
|
|
15
|
+
var triggerPoint = 0;
|
|
16
|
+
|
|
17
|
+
// Create decade links in timeline
|
|
18
|
+
function buildTimelineNavigation() {
|
|
19
|
+
[].forEach.call(decades, function (decade) {
|
|
20
|
+
var decadeLink = document.createElement('a');
|
|
21
|
+
var textContent = decade.textContent;
|
|
22
|
+
|
|
23
|
+
decadeLink.setAttribute('href', '#' + textContent);
|
|
24
|
+
decadeLink.innerText = textContent;
|
|
25
|
+
decadeContainer.appendChild(decadeLink);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Set trigger point (vertical position in viewport)
|
|
30
|
+
for when a new decade should start being "active" */
|
|
31
|
+
function setTriggerPoint() {
|
|
32
|
+
triggerPoint = window.innerHeight * 0.5;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Animate progress bar when user is scolling within the timeline
|
|
36
|
+
function animateProgressBar() {
|
|
37
|
+
var currentSection = 0;
|
|
38
|
+
var sectionIndex = 0;
|
|
39
|
+
var currentPosition = document.documentElement.scrollTop + triggerPoint;
|
|
40
|
+
var decadeLinks = document.querySelectorAll('.js-decade-container a');
|
|
41
|
+
var progressBarWidth = 0;
|
|
42
|
+
|
|
43
|
+
// Check if we are above the first section
|
|
44
|
+
if (currentPosition < offsetTop(firstDecade)) {
|
|
45
|
+
currentSection = 0;
|
|
46
|
+
progressBarWidth = 0;
|
|
47
|
+
progressBar.style.width = '0';
|
|
48
|
+
|
|
49
|
+
[].forEach.call(decadeLinks, function (decadeLink) {
|
|
50
|
+
decadeLink.classList.remove('is-reading');
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
// Otherwise add 1 to sectionIndex while scrolling;
|
|
54
|
+
[].forEach.call(decades, function (decade) {
|
|
55
|
+
var sectionTop = offsetTop(decade);
|
|
56
|
+
|
|
57
|
+
if (currentPosition >= sectionTop) {
|
|
58
|
+
currentSection = sectionIndex;
|
|
59
|
+
|
|
60
|
+
[].forEach.call(decadeLinks, function (decadeLink) {
|
|
61
|
+
decadeLink.classList.remove('is-reading');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
decadeLinks[sectionIndex].classList.add('is-reading');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
sectionIndex += 1;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Calculate speed of the progressBar width while scrolling based on section height
|
|
72
|
+
var startPoint = decadeLinks[currentSection];
|
|
73
|
+
var startPointX = offsetLeft(startPoint);
|
|
74
|
+
var startPointWidth = startPoint.offsetWidth;
|
|
75
|
+
var startSection = decadeSections[currentSection];
|
|
76
|
+
var startSectionY = offsetTop(startSection);
|
|
77
|
+
var endSectionY = offsetBottom(startSection);
|
|
78
|
+
var sectionLength = endSectionY - startSectionY;
|
|
79
|
+
var scrollY = currentPosition - startSectionY;
|
|
80
|
+
var sectionProgress = scrollY / sectionLength;
|
|
81
|
+
progressBarWidth = startPointX + startPointWidth * sectionProgress;
|
|
82
|
+
|
|
83
|
+
// Use result to animate progressbar
|
|
84
|
+
progressBar.style.width = progressBarWidth + 'px';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Run functions on page load
|
|
88
|
+
if (progressBar) {
|
|
89
|
+
buildTimelineNavigation();
|
|
90
|
+
setTriggerPoint();
|
|
91
|
+
animateProgressBar();
|
|
92
|
+
|
|
93
|
+
// Re-run functions on window events
|
|
94
|
+
window.addEventListener('resize', function () {
|
|
95
|
+
setTriggerPoint();
|
|
96
|
+
animateProgressBar();
|
|
97
|
+
});
|
|
98
|
+
window.addEventListener('scroll', function () {
|
|
99
|
+
animateProgressBar();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// DUMMY TIMELINE ITEM OPEN/CLOSE
|
|
104
|
+
/*
|
|
105
|
+
function wrap(el, wrapper) {
|
|
106
|
+
el.parentNode.insertBefore(wrapper, el);
|
|
107
|
+
wrapper.classList.add('wrapper');
|
|
108
|
+
wrapper.appendChild(el);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const timeLineItems = document.querySelectorAll('.js-timeline-item');
|
|
112
|
+
let timeLineItemScrollPosition = 0;
|
|
113
|
+
|
|
114
|
+
[].forEach.call(timeLineItems, (timeLineItem) => {
|
|
115
|
+
const timeLineItemLink = timeLineItem.querySelector('a');
|
|
116
|
+
const timeLineItemClose = timeLineItem.querySelector('.js-timeline-item-close');
|
|
117
|
+
const timeLineItemBottomClose = timeLineItem.querySelector('.js-timeline-item-bottom-close');
|
|
118
|
+
|
|
119
|
+
timeLineItemLink.addEventListener('click', () => {
|
|
120
|
+
timeLineItemScrollPosition = window.pageYOffset;
|
|
121
|
+
sessionStorage.setItem('scroll-position', timeLineItemScrollPosition);
|
|
122
|
+
|
|
123
|
+
if (!timeLineItem.classList.contains('is-open')) {
|
|
124
|
+
timeLineItem.classList.add('is-open');
|
|
125
|
+
timeLineItem.closest('.row').classList.add('row-has-open-child');
|
|
126
|
+
|
|
127
|
+
// Wrap open timeline item
|
|
128
|
+
wrap(timeLineItem.querySelector('.wp-block-iis-timeline-post'),
|
|
129
|
+
document.createElement('div'));
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
timeLineItemClose.addEventListener('click', () => {
|
|
134
|
+
timeLineItem.classList.remove('is-open');
|
|
135
|
+
timeLineItem.closest('.row').classList.remove('row-has-open-child');
|
|
136
|
+
|
|
137
|
+
// Destroy generated wrapper
|
|
138
|
+
const wrapper = timeLineItemClose.nextElementSibling;
|
|
139
|
+
wrapper.replaceWith(...wrapper.childNodes);
|
|
140
|
+
|
|
141
|
+
const top = sessionStorage.getItem('scroll-position');
|
|
142
|
+
if (top !== null) {
|
|
143
|
+
window.scrollTo(0, parseInt(top, 10));
|
|
144
|
+
}
|
|
145
|
+
sessionStorage.removeItem('scroll-position');
|
|
146
|
+
|
|
147
|
+
// Trigger scroll event to reveal timeline items not yet parallaxed into view
|
|
148
|
+
window.dispatchEvent(new CustomEvent('scroll'));
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
timeLineItemBottomClose.addEventListener('click', () => {
|
|
152
|
+
timeLineItemClose.click();
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
*/
|