Add latest changes of sources files

This commit is contained in:
Eduardo 2019-06-16 14:52:36 +02:00
parent 161f4845c5
commit 55533f8ca4
2 changed files with 92 additions and 81 deletions

View file

@ -4,86 +4,98 @@ import stickybits from 'stickybits'
import mediumZoom from 'medium-zoom' import mediumZoom from 'medium-zoom'
import fitvids from 'fitvids' import fitvids from 'fitvids'
$(document).ready(() => { let $progressCircle = null
fitvids('.js-post-content') let lastScrollingY = window.pageYOffset
let lastWindowHeight = 0
let lastDocumentHeight = 0
let circumference = 0
let isTicking = false
function isMobile(width = '768px') {
return window.matchMedia(`(max-width: ${width})`).matches
}
function onScrolling() {
lastScrollingY = window.pageYOffset
requestTicking()
}
function onResizing() {
setHeights()
adjustShare(100)
setTimeout(() => {
setCircleStyles()
requestTicking()
}, 200)
}
function requestTicking() {
if (!isTicking) {
requestAnimationFrame(updating)
}
isTicking = true
}
function updating() {
const progressMax = lastDocumentHeight - lastWindowHeight
const percent = Math.ceil((lastScrollingY / progressMax) * 100)
if (percent <= 100) {
setProgress(percent)
}
isTicking = false
}
function setHeights() {
lastWindowHeight = window.innerHeight
lastDocumentHeight = $(document).height()
}
function setCircleStyles() {
const radiusCircle = $progressCircle.parent().width() / 2
const borderWidth = isMobile() ? 2 : 3
$progressCircle.attr('stroke-width', borderWidth)
$progressCircle.attr('r', radiusCircle - (borderWidth - 1))
$progressCircle.attr('cx', radiusCircle)
$progressCircle.attr('cy', radiusCircle)
circumference = radiusCircle * 2 * Math.PI
$progressCircle[0].style.strokeDasharray = `${circumference} ${circumference}`
$progressCircle[0].style.strokeDashoffset = circumference
}
function setProgress(percent) {
if (percent <= 100) {
const offset = circumference - percent / 100 * circumference
$progressCircle[0].style.strokeDashoffset = offset
}
}
function prepareProgressCircle() {
$progressCircle = $('.js-progress')
setHeights()
setCircleStyles()
updating()
setTimeout(() => {
$progressCircle.parent().css('opacity', 1)
}, 300)
}
$(document).ready(() => {
const $aosWrapper = $('.js-aos-wrapper') const $aosWrapper = $('.js-aos-wrapper')
const $progressCircle = $('.js-progress')
const $scrollButton = $('.js-scrolltop') const $scrollButton = $('.js-scrolltop')
const $loadComments = $('.js-load-comments') const $loadComments = $('.js-load-comments')
const $commentsIframe = $('.js-comments-iframe') const $commentsIframe = $('.js-comments-iframe')
const $recommendedArticles = $('.js-recommended-articles') const $recommendedArticles = $('.js-recommended-articles')
let lastScrollingY = window.pageYOffset fitvids('.js-post-content')
let lastWindowHeight = 0
let lastDocumentHeight = 0
let circumference = 0
let isTicking = false
function isMobile(width = '768px') {
return window.matchMedia(`(max-width: ${width})`).matches
}
function onScrolling() {
lastScrollingY = window.pageYOffset
requestTicking()
}
function onResizing() {
setHeights()
adjustShare(100)
setTimeout(() => {
setCircleStyles()
requestTicking()
}, 200)
}
function requestTicking() {
if (!isTicking) {
requestAnimationFrame(updating)
}
isTicking = true
}
function updating() {
const progressMax = lastDocumentHeight - lastWindowHeight
const percent = Math.ceil((lastScrollingY / progressMax) * 100)
if (percent <= 100) {
setProgress(percent * 1.5)
}
isTicking = false
}
function setHeights() {
lastWindowHeight = window.innerHeight
lastDocumentHeight = $(document).height()
}
function setCircleStyles() {
const radiusCircle = $progressCircle.parent().width() / 2
const borderWidth = isMobile() ? 2 : 3
$progressCircle.attr('stroke-width', borderWidth)
$progressCircle.attr('r', radiusCircle - (borderWidth - 1))
$progressCircle.attr('cx', radiusCircle)
$progressCircle.attr('cy', radiusCircle)
circumference = radiusCircle * 2 * Math.PI
$progressCircle[0].style.strokeDasharray = `${circumference} ${circumference}`
$progressCircle[0].style.strokeDashoffset = circumference
}
function setProgress(percent) {
if (percent <= 100) {
const offset = circumference - percent / 100 * circumference
$progressCircle[0].style.strokeDashoffset = offset
}
}
function adjustImageGallery() { function adjustImageGallery() {
const images = document.querySelectorAll('.kg-gallery-image img') const images = document.querySelectorAll('.kg-gallery-image img')
@ -113,10 +125,8 @@ $(document).ready(() => {
adjustShare(1000) adjustShare(1000)
if ($recommendedArticles.length > 0) { if ($recommendedArticles.length > 0) {
$recommendedArticles.on('init', function() { $recommendedArticles.on('init', function () {
setHeights() prepareProgressCircle()
setCircleStyles()
updating()
}) })
$recommendedArticles.slick({ $recommendedArticles.slick({
@ -141,10 +151,6 @@ $(document).ready(() => {
} }
] ]
}) })
} else {
setHeights()
setCircleStyles()
updating()
} }
$scrollButton.click(() => { $scrollButton.click(() => {
@ -174,3 +180,7 @@ $(document).ready(() => {
window.addEventListener('scroll', onScrolling, { passive: true }) window.addEventListener('scroll', onScrolling, { passive: true })
window.addEventListener('resize', onResizing, { passive: true }) window.addEventListener('resize', onResizing, { passive: true })
}) })
$(window).on('load', () => {
prepareProgressCircle()
})

View file

@ -205,6 +205,7 @@
top: 0; top: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
opacity: 0;
circle { circle {
transform-origin: 50% 50%; transform-origin: 50% 50%;