Skip to content

Instantly share code, notes, and snippets.

Avatar

Tim Rijkse timrijkse

View GitHub Profile
@timrijkse
timrijkse / smooth-scroll.js
Last active Oct 10, 2019
Smooth scroll example GSAP+Vue
View smooth-scroll.js
<template>
<div class="page" :style="{height: `${pageHeight}px`" }>
<div ref="page" class="page-inner">
</div>
</template>
<script>
import { TimelineMax, TweenMax, Linear } from 'gsap'
@timrijkse
timrijkse / scroll-percentage.js
Created Oct 8, 2019
Get scroll percentage of element. When the top of the element hits the top of the screen percentage will be 0. When the bottom of the element hits the bottom of the screen percentage will be 100.
View scroll-percentage.js
const { top, height } = this.$el.getBoundingClientRect()
const { pageYOffset, innerHeight } = window
const min = top + pageYOffset
const max = min + height - innerHeight
const percentage = ((pageYOffset - min) * 100) / (max - min)
@timrijkse
timrijkse / paginator.js
Created Jan 23, 2017
paginator mixin for vue
View paginator.js
import clamp from 'lodash/clamp'
export default {
props: {
/**
* The items inside the paginator
*/
items: {
type: Array,