Skip to content

Commit

Permalink
allow autoscroll params to be passed
Browse files Browse the repository at this point in the history
  • Loading branch information
maboa committed Feb 16, 2021
1 parent 72c487e commit d31c291
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -993,10 +993,11 @@ <h5 data-m="214800">What kind of help is available for people to manage their ow

// minimizedMode is still experimental - it aims to show the current words in the title, which can be seen on the browser tab.
var minimizedMode = false;
var autoScroll = false;
var autoScroll = true;

var ht1 = hyperaudiolite();
ht1.init("hypertranscript", "hyperplayer", minimizedMode, autoScroll);
//ht1.setScrollParameters(<duration>, <delay>, <offset>, <container>);

</script>

Expand Down
47 changes: 38 additions & 9 deletions js/hyperaudio-lite.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ var hyperaudiolite = (function () {
windowHash,
hashArray,
hashVar,
velocity,
scroller,
scrollerContainer,
scrollerDuration,
scrollerDelay,
scrollerOffset,
autoscroll;


Expand Down Expand Up @@ -50,7 +54,12 @@ var hyperaudiolite = (function () {
minimizedMode = m;
textShot = "";
wordIndex = 0;

autoscroll = a;
scrollerContainer = transcript;
scrollerOffset = 0;
scrollerDuration = 800;
scrollerDelay = 0;

//Create the array of timed elements (wordArr)

Expand Down Expand Up @@ -164,9 +173,11 @@ var hyperaudiolite = (function () {
}
}

velocity = window.Velocity || window.jQuery.Velocity;
scroller = window.Velocity || window.jQuery.Velocity;
}



function getSelectionMediaFragment() {

var fragment = "";
Expand Down Expand Up @@ -352,12 +363,23 @@ var hyperaudiolite = (function () {

if (currentParaIndex != paraIndex) {

if (typeof velocity !== 'undefined' && autoscroll === true) {
velocity(scrollNode, "scroll", {
container: transcript,
duration: 800,
delay: 0
});
if (typeof scroller !== 'undefined' && autoscroll === true) {

if (typeof(scrollerContainer) !== 'undefined' && scrollerContainer !== null) {

scroller(scrollNode, "scroll", {
container: scrollerContainer,
duration: scrollerDuration,
delay: scrollerDelay,
offset: scrollerOffset
});
} else {
scroller(scrollNode, "scroll", {
duration: scrollerDuration,
delay: scrollerDelay,
offset: scrollerOffset
});
}
}

newPara = true;
Expand Down Expand Up @@ -405,6 +427,13 @@ var hyperaudiolite = (function () {
//set minimizedMode is an experimental feature
}

hal.setScrollParameters = function(duration, delay, offset, container) {
scrollerContainer = container;
scrollerDuration = duration;
scrollerDelay = delay;
scrollerOffset = offset;
}

return hal;

});
});

0 comments on commit d31c291

Please sign in to comment.