@@ -62,6 +62,16 @@ playbackRate callback every n secs of the video's timeline
6262I'm not sure what the supposed "snap to boundaries" stuff @FWPHUNKM is *really*
6363doing. Particularly, the 'cur_clust' array is not used for anything at all.
6464
65+ * * *
66+
67+ Setting USE_TIMELINE_X > 0 below means that we will be able to see all of the first preview image,
68+ but when we are at the start of the video, it means that the first time marker is at the
69+ position of USE_TIMELINE_X (so that everything to the left of it would be negative time). Doing
70+ this then messes up our calculations for get_visual_time_bounds(), with the result being
71+ that it is possible for the marker to move off the right edge of the window, but it
72+ is still taken to be visible by the logic. So to be perfectly "pixel precise" about everything,
73+ we need to figure out how to account for USE_TIMELINE_X.
74+
6575»*/
6676/*9/9/25:«
6777
@@ -209,6 +219,8 @@ ALL OF THE ISSUES CENTER AROUND THE PADDING GIMMICK @WJHGLVG.
209219
210220//let GRID_W = 125;
211221let GRID_W = 175 ;
222+ let USE_TIMELINE_X = GRID_W / 2 ;
223+ //let USE_TIMELINE_X = 0;
212224
213225//Vars«
214226
@@ -308,7 +320,6 @@ let total_scroll;
308320//let TIMELINE_H = 35;
309321let TIMELINE_H = 42 ;
310322//let TIMELINE_H = 35;
311- let USE_TIMELINE_X = 0 ;
312323let PIX_PER_SEC = 10 ;
313324
314325let MAX_MAG_LEVEL = 10000 ;
@@ -364,6 +375,8 @@ let TLX;
364375
365376let use_padl = 0 ;
366377
378+ let USE_ADJ_SEC = USE_TIMELINE_X / mag_pix_per_sec ;
379+
367380//»
368381
369382//DOM«
@@ -491,14 +504,17 @@ Main._add(overdiv);
491504const bot_wrap = make ( 'div' ) ;
492505bot_wrap . _pos = "absolute" ;
493506bot_wrap . _b = 0 ;
507+ bot_wrap . _bgcol = "#000" ;
494508bot_wrap . _w = "100%" ;
495509bot_wrap . _add ( img_div ) ;
496510bot_wrap . _add ( timeline ) ;
497511
512+ //bot_wrap._x = USE_TIMELINE_X;
513+ bot_wrap . _padl = USE_TIMELINE_X ;
514+ //bot_wrap._padl = USE_TIMELINE_X;
498515//bot_wrap._padl = GRID_W_HALF/2;
499516
500517Main . _add ( bot_wrap ) ;
501-
502518//log(img_div);
503519//log(timeline);
504520
@@ -1123,7 +1139,7 @@ cwarn("No output");
11231139 }
11241140 is_waiting = false ;
11251141} ; //»
1126-
1142+ /*
11271143const scroll_elem = (elem, tm, x_off, bounds_start_arg)=>{//«
11281144 let offset = get_timeline_offset(tm, bounds_start_arg);
11291145 if (offset < -10||offset>Main._w+10) elem._dis = "none";
@@ -1137,6 +1153,20 @@ mark._scroll = ()=>{
11371153 scroll_elem(mark, vid.currentTime, TIME_MARK_X_OFF);
11381154}
11391155//»
1156+ */
1157+ const scroll_elem = ( elem , tm , x_off , bounds_start_arg ) => { //«
1158+ let offset = get_timeline_offset ( tm , bounds_start_arg ) ;
1159+ // if (offset < -10||offset>Main._w+10) elem._dis = "none";
1160+ // else{
1161+ elem . _dis = "" ;
1162+ elem . _x = x_off + offset ;
1163+ elem . _padl = use_padl ;
1164+ // }
1165+ } ;
1166+ mark . _scroll = ( ) => {
1167+ scroll_elem ( mark , vid . currentTime , TIME_MARK_X_OFF ) ;
1168+ }
1169+ //»
11401170const scroll_timeline = ( which , opts = { } ) => { //«
11411171/*
11421172This is either called by scroll_time_marker or by handle_arrow.
@@ -1161,8 +1191,8 @@ This is either called by scroll_time_marker or by handle_arrow.
11611191 }
11621192 let gotx = tm_x + inc ;
11631193
1164- let diff = Main . _w - ( ( viddur + ( gotx / mag_pix_per_sec ) ) * mag_pix_per_sec ) ;
11651194 let did_adjust = false ;
1195+ let diff = Main . _w - ( ( viddur + ( gotx / mag_pix_per_sec ) ) * mag_pix_per_sec ) ;
11661196 if ( diff > 0 ) {
11671197//log("DID ADJUST", diff);
11681198// did_adjust = true;
@@ -1215,12 +1245,12 @@ const scroll_time_marker = (which, opts={}) => {//«
12151245 else if ( gotto < 0 ) gotto = 0 ;
12161246 let round_to = round_ms ( gotto ) ;
12171247 if ( dir > 0 ) {
1218- if ( round_to > round_ms ( get_visual_time_bounds ( ) . end ) ) {
1248+ if ( round_to > round_ms ( get_visual_time_bounds ( ) . end - USE_ADJ_SEC ) ) {
12191249 scroll_timeline ( "RIGHT" ) ;
12201250 }
12211251 }
12221252 else {
1223- if ( round_to < round_ms ( get_visual_time_bounds ( ) . start ) ) {
1253+ if ( round_to < round_ms ( get_visual_time_bounds ( ) . start - USE_ADJ_SEC ) ) {
12241254 scroll_timeline ( "LEFT" ) ;
12251255 }
12261256 }
@@ -1478,9 +1508,13 @@ if (flush_right_edge()){
14781508 return ;
14791509}
14801510 let bounds = get_visual_time_bounds ( ) ;
1481- let ctr_time = ( bounds . end + bounds . start ) / 2 ;
1511+ // let ctr_time = (bounds.end + bounds.start)/2;
1512+ let ctr_time = ( ( bounds . end + bounds . start ) / 2 ) - USE_ADJ_SEC ;
14821513 let off_secs = tm - ctr_time ;
1483- off_secs -= ( off_secs % mag_sec_per_grid ) ;
1514+ //If we don't make this adjustment, then all times on the right side are one grid square too far to the right
1515+ if ( off_secs > 0 ) off_secs ++ ;
1516+ //log(off_secs);
1517+ off_secs -= ( off_secs % mag_sec_per_grid ) ; //Snap to grid so the ruler times are "nice"
14841518 let pix_off = mag_pix_per_sec * off_secs ;
14851519 timeline . _xLoc -= pix_off ;
14861520//If the start marker is past the left edge of the app window, always flush it to to the left
@@ -1511,7 +1545,8 @@ The video stays at the end.
15111545 return true ;
15121546} //»
15131547const seek_to_end = async ( ) => { //«
1514- timeline . _xLoc = Main . _w - timeline . _width - GRID_W_HALF ;
1548+ timeline . _xLoc = Main . _w - timeline . _width - GRID_W ;
1549+ // timeline._xLoc = Main._w - timeline._width - GRID_W_HALF;
15151550 align_timeline ( ) ;
15161551//AQUEORK
15171552// await seek_to_time(viddur-0.001, true);
@@ -1557,16 +1592,55 @@ mark._maybeScroll=()=>{
15571592
15581593//»
15591594const get_timeline_rect = ( ) => { //«
1560- return {
1561- left : timeline . _xLoc ,
1562- right : timeline . _xLoc + timeline . _width ,
1563- width : timeline . _width
1564- } ;
1595+ let use_off = 0 ;
1596+ //let use_off = USE_TIMELINE_X;
1597+ return {
1598+ left : timeline . _xLoc - use_off ,
1599+ right : timeline . _xLoc + timeline . _width - use_off ,
1600+ width : timeline . _width
1601+ } ;
1602+ } ; //»
1603+
1604+ const get_visual_time_bounds = ( ) => { //«
1605+
1606+ let tr = get_timeline_rect ( ) ;
1607+ let mw = Main . _w ;
1608+
1609+ let left_edge = 0 > tr . left ? 0 : tr . left ;
1610+ let right_edge = mw < tr . right ? mw : tr . right ;
1611+
1612+ let viz_duration = ( right_edge - left_edge ) / mag_pix_per_sec ;
1613+
1614+ let viz_start ;
1615+ let viz_end ;
1616+
1617+ let left_diff = tr . left ;
1618+ if ( left_diff > 0 ) {
1619+ if ( tr . left > mw ) {
1620+ return { invalid : true , type : 1 } ;
1621+ }
1622+ viz_start = 0 ;
1623+ }
1624+ else {
1625+ if ( tr . right < 0 ) {
1626+ return { invalid : true , type : 2 , diff : - tr . right } ;
1627+ }
1628+ viz_start = - left_diff / mag_pix_per_sec ;
1629+ }
1630+ viz_end = viz_start + viz_duration ;
1631+
1632+ return {
1633+ start : viz_start ,
1634+ end : viz_end ,
1635+ duration : viz_duration ,
1636+ width : viz_duration * mag_pix_per_sec
1637+ } ;
1638+
15651639} ; //»
1566- const get_visual_time_bounds = ( ) => { //«
1640+ /*
1641+ const get_visual_time_bounds = () => {//«
15671642
15681643let rr = get_timeline_rect();
1569- //log("RR", rr);
15701644let mw = Main._w;
15711645
15721646let left_edge = 0 > rr.left ? 0 : rr.left;
@@ -1582,7 +1656,6 @@ let viz_end;
15821656let left_diff = rr.left;
15831657if (left_diff > 0){
15841658 let diff = rr.left - mw;
1585- //log(1, diff);
15861659 if (rr.left > mw){
15871660 return {invalid: true, type: 1};
15881661 }
@@ -1600,12 +1673,11 @@ return {
16001673 start: viz_start,
16011674 end: viz_end,
16021675 duration: viz_duration,
1603- startDiff : left_diff ,
16041676 width: viz_duration * mag_pix_per_sec
16051677};
16061678
16071679};//»
1608-
1680+ */
16091681const scroll_to_time = ( tm , which ) => { //«
16101682 vid . currentTime = tm ;
16111683 tmdiv . innerHTML = get_main_time_str ( tm ) ;
@@ -1701,14 +1773,14 @@ v.onloadedmetadata=async()=>{//«
17011773 d . _op = VID_IMG_OP ;
17021774 d . _add ( im ) ;
17031775 img_div . _add ( d ) ;
1704- if ( tm == viddur ) {
1776+ // if (tm==viddur){
17051777// d._x = m._x;
1706- d . _x = use_padl + m . _x ;
1707- }
1708- else {
1778+ // d._x = use_padl + m._x;
1779+ // }
1780+ // else{
17091781 d . _x = use_padl + m . _x - w / 2 ;
17101782// d._x = use_padl + m._x;
1711- }
1783+ // }
17121784 d . _z = 10 ;
17131785 d . style . borderRight = PREV_IMG_BORDER ;
17141786 d . style . borderLeft = PREV_IMG_BORDER ;
@@ -1734,11 +1806,9 @@ for (let im of cur_images) im._del();
17341806
17351807let {
17361808 invalid,
1737- startDiff : left_diff ,
17381809 start : viz_start ,
17391810 end : viz_end ,
17401811 duration : viz_duration ,
1741- width : viz_width
17421812} = get_visual_time_bounds ( ) ;
17431813
17441814if ( invalid ) {
@@ -1767,7 +1837,7 @@ grid_marks = [];
17671837cur_images = [ ] ;
17681838//images_showing = true;
17691839let last_x ;
1770- let first_x ;
1840+ // let first_x;
17711841for ( let i = - 1 ; i < num_grids ; i ++ ) {
17721842 let g = mkdv ( ) ;
17731843 grid_marks . push ( g ) ;
@@ -1776,6 +1846,7 @@ for (let i=-1; i < num_grids; i++){
17761846 g . _bgcol = "#555" ;
17771847 g . _h = "100%" ;
17781848 g . _x = ( ( i + 1 ) * GRID_W ) - 1 ;
1849+ last_x = g . _x ;
17791850 g . _y = 0 ;
17801851 g . _z = 1 ;
17811852 ruler . _add ( g ) ;
@@ -1821,7 +1892,9 @@ if (Math.abs(viz_end-viddur) < 0.01){
18211892*/
18221893// if (opts.addLast) {
18231894// grid_time_elems.push({});
1824- // grid_marks.push(g);
1895+ //If the x value is < GRID_W_HALF from the previous one, do not add this
1896+ //log(g._x - last_x,GRID_W_HALF);
1897+ if ( g . _x - last_x >= GRID_W_HALF ) grid_marks . push ( g ) ;
18251898// }
18261899 ruler . _add ( g ) ;
18271900
@@ -1930,6 +2003,7 @@ return;
19302003let bnds = get_visual_time_bounds ( ) ;
19312004cur_mag_level ++ ;
19322005mag_pix_per_sec = MAG_PIX_PER_SEC_ARR [ cur_mag_level ] ;
2006+ USE_ADJ_SEC = USE_TIMELINE_X / mag_pix_per_sec ;
19332007mag_sec_per_grid = GRID_W / mag_pix_per_sec ;
19342008timeline_sig_figs = ( mag_pix_per_sec + "" ) . length - 2 ;
19352009if ( timeline_sig_figs < 0 ) timeline_sig_figs = 0 ;
@@ -1955,6 +2029,7 @@ if (cur_mag_level-1 < 0){
19552029}
19562030cur_mag_level -- ;
19572031mag_pix_per_sec = MAG_PIX_PER_SEC_ARR [ cur_mag_level ] ;
2032+ USE_ADJ_SEC = USE_TIMELINE_X / mag_pix_per_sec ;
19582033mag_sec_per_grid = GRID_W / mag_pix_per_sec ;
19592034let w = timeline . _width ;
19602035timeline . _width = viddur * mag_pix_per_sec ;
@@ -2353,7 +2428,7 @@ slice, and if so, seek to the start of the next slice.
23532428
23542429Otherwise, we can do the check for being past the end of the current visual boundary as below.
23552430*/
2356- if ( ctime > get_visual_time_bounds ( ) . end ) {
2431+ if ( ctime > get_visual_time_bounds ( ) . end - USE_ADJ_SEC ) {
23572432// handle_arrow("RIGHT_S"); //For some reason, using handle_arrow does NOT render the preview images
23582433 scroll_timeline ( "RIGHT" ) ; //This automatically renders the preview images
23592434 }
@@ -2420,7 +2495,8 @@ this.onkeydown=(e,k)=>{//«
24202495 }
24212496 else if ( k == "c_" ) {
24222497 let { start, end} = get_visual_time_bounds ( ) ;
2423- seek_to_time ( ( start + end ) / 2 ) ;
2498+ // seek_to_time((start+end)/2);
2499+ seek_to_time ( ( ( start + end ) / 2 ) - USE_ADJ_SEC ) ;
24242500 }
24252501 else if ( k == "s_C" ) {
24262502 try_save ( ) ;
0 commit comments