Skip to content

Commit eb8ef61

Browse files
committed
Move scroll to center changes to src and bump version to 0.8.1
1 parent 324edfe commit eb8ef61

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

bower.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "videojs-transcript",
3-
"version": "0.1",
3+
"version": "0.8.1",
44
"dependencies": {
55
"video.js": "5.13.1"
66
},
7-
"homepage": "https://github.com/raccoongang/videojs-transcript",
7+
"homepage": "https://github.com/walsh9/videojs-transcript",
88
"authors": [
99
"walsh9"
1010
],

dist/videojs-transcript.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/*! videojs-transcript - v0.8.0 - 2016-02-21
2-
* Copyright (c) 2016 Matthew Walsh; Licensed MIT */
1+
/*! videojs-transcript - v0.8.1 - 2017-04-21
2+
* Copyright (c) 2017 Matthew Walsh; Licensed MIT */
33
(function (window, videojs) {
44
'use strict';
55

dist/videojs-transcript.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "videojs-transcript",
3-
"version": "0.8.0",
3+
"version": "0.8.1",
44
"author": "Matthew Walsh",
55
"description": "Creates interactive transcripts from text tracks.",
66
"license": "MIT",

src/options.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ var defaults = {
1515
showTitle: true,
1616
showTrackSelector: true,
1717
followPlayerTrack: true,
18+
scrollToCenter: false,
1819
stopScrollWhenInUse: true,
1920
};

src/scroller.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,21 @@ var scrollerProto = function(plugin) {
8888
var elementOffsetBottom = element.offsetTop + element.clientHeight;
8989
var relTop = element.offsetTop - parent.offsetTop;
9090
var relBottom = (element.offsetTop + element.clientHeight) - parent.offsetTop;
91+
var centerPosCorrection = 0;
9192
var newPos;
9293

94+
if (plugin.settings.scrollToCenter){
95+
centerPosCorrection = Math.round(parent.clientHeight/2 - element.clientHeight/2);
96+
}
9397
// If the top of the line is above the top of the parent view, were scrolling up,
9498
// so we want to move the top of the element downwards to match the top of the parent.
95-
if (relTop < parent.scrollTop) {
96-
newPos = element.offsetTop - parent.offsetTop;
99+
if (relTop < parent.scrollTop + centerPosCorrection) {
100+
newPos = element.offsetTop - parent.offsetTop -centerPosCorrection;
97101

98102
// If the bottom of the line is below the parent view, we're scrolling down, so we want the
99103
// bottom edge of the line to move up to meet the bottom edge of the parent.
100-
} else if (relBottom > (parent.scrollTop + parent.clientHeight)) {
101-
newPos = elementOffsetBottom - parentOffsetBottom;
104+
} else if (relBottom > (parent.scrollTop + parent.clientHeight) - centerPosCorrection) {
105+
newPos = elementOffsetBottom - parentOffsetBottom + centerPosCorrection;
102106
}
103107

104108
// Don't try to scroll if we haven't set a new position. If we didn't

0 commit comments

Comments
 (0)