Skip to content

Instantly share code, notes, and snippets.

View ryangittings's full-sized avatar

Ryan Gittings ryangittings

View GitHub Profile
@ryangittings
ryangittings / PerchTemplateFilter_Length
Created May 13, 2019 10:24
Perch template filter for getting a Perch item's reading length in minutes
<?php
class PerchTemplateFilter_length extends PerchTemplateFilter
{
public function filterBeforeProcessing($value, $valueIsMarkup = false)
{
$word = str_word_count(strip_tags($value));
$m = floor($word / 200);
$s = floor($word % 200 / (200 / 60));
var scrollElement = function (element, scrollPosition, duration) {
var style = element.style;
// setup CSS transition duration and easing function
style.webkitTransition =
style.transition = duration + 's';
style.webkitTransitionTimingFunction =
style.TransitionTimingFunction = 'ease-in-out';
// use translate3d to force hardware acceleration