A Browser Emulator Specification
In my quest to prove true web pages, I had to present legacy and refactored designs for comparisons.
In many cases, the designs are of different heights, with parts at different vertical positions, across different areas, making comparisons harder to make, forcing the eyes to oscillate up and down across sides.
If both designs use the same viewports, capped at the same heights, with designs scrolling within the viewports, manually or automatically, easing-in the begining of a part to the viewport top and easing-out the end of a part to the viewport end — when automated, it will be much easier to compare components of both designs with less stress to the eyes.
Hence, the need of a two-tab browser emulator. The manual scrolling helps with custom alignments for comparisons, while the automatic scrolling, with controls to scroll, speed, pause, stop, maximize, and minimize, help with a quick overview.
Document Structure
The document is expected to be structured as below:
-
One
dialog#fullscreen-modalelement, to hold a browser emulator in fullscreen mode when the modal is opened. -
One or more
.browserelements, the browser emulators, each with the following descendants:-
One
.tab-groupelement, with adata-track-keyattribute specifying the animation data from thetracksparameter to be used for the mockups within the tab group.-
One
.tab.tab-oneelement, and, optionally, one.tab.tab-twoelement, acting as viewports.Each contains an
img.mockupelement for an unsplit mockup, or ansvg.mockupelement for a split mockup.
-
-
One
button.sizeelement, a control containing two icons: an unhidden.minimize-icon, and a hidden.maximize-icon, both display model corresponding to the state of the modal dialog.It may have a
data-targetattribute to refer to another ancestor over the Browser Emulator to transport in and out of the fullscreen mode. -
One
button.playcontrol element, containing two icons: an unhidden.play-icon, and a hidden.pause-icon, corresponding to the initial state of the mockups. -
button.stopcontrol element, disabled by default since mockups are not scrolling. -
select.speedcontrol element.
-
App Interface
Create a Javascript module, exporting the class named BrowserEmulator, accepting a `tracks` parameter with the following data structure: c1
const tracks = {
tabGroup: {
y1: number[],
y2: number[],
duration: number,
times?: number[]
}
}
Where:
-
tabGroupis the value of thedata-track-keyon the.tab-groupwithin a browser emulator. -
y1andy2are keyframes for the.mockupof.tab-oneand.tab-twoviewports respectively, where components align in a pre-chosen viewport.The last items must be the maximum scroll value of the chosen viewport to make all values responsive to any viewport.
-
durationis the no of seconds it must take both mockups to finish scrolling. -
timesprovides the timing to maintain uniform speed across both mockups.It is optional if keyframes are progressive in values, as there will be no need to factor in the time it takes to rewind a scene.
Dependencies
App Behavior
For each browser emulator, their controls modify their mockups as follows:
Minimize & Maximaze Control
A click on button.size either maximize or minimize the target using the following process:m1
-
Query the target whose ID is provided in the
data-targeton this control. If no ID, it defaults to the browser emulator itself.m2 -
If
dialog#fullscreen-modalis closed:-
Move the target to this modal.m3
-
Show the modal.m4
-
Hide the
.maximize-icon, and unhide the.minimize-icon; to match the state of the modal.m5
-
-
Else, if the modal is opened:
-
Return the target back to its original position in the DOM.m6
-
Close the modal.m7
-
Unhide the
.maximize-icon, and hide the.minimize-icon; to match the new state of the modal.m8
-
-
Maintain focus on this control when modal is opened or closed.m9
Speed Control
A change of select.speed set or modify the speed of scrolling mockups as follows:f1
-
If no active mockup animation, do nothing, setting the value for the next time an animation will run.f2
-
Else, if mockup animations are active, modify the speed of the animation.f3
Play & Pause Control
A click on button.play simulate scrolling of the mockups using the following process:p1
-
Enable
button.stopto stop active simulations, be it running or paused simulation.p2 -
Veil the scrollbar of each
.tabviewport, to disallow any intervention while simulating the scrolling.p3 -
If animation states of mockups are idle, as expected by default, scroll the viewports and translate the mockups as follows:p4
-
Reset any manual scrolls by smoothly scrolling the viewports to the top, then force a delay of 250s before translating the mockups.p5
-
Using the Motion Library, translate, vertically, the
.mockupof.tab-oneand.tab-twoviewports based on thetracksdata whose key is retrieved from thedata-track-keyof the mockups'.tab-group, with the following in mind:p6-
For responsiveness of the keyframes, remap the items of
y1andy2arrays such that their last item is the maximum scroll value of the current.tabviewport.p7 -
If
timesis not provided, maintain uniform speed on both mockups by generating a single timing, based on whichever ofy1andy2has the greater last item.p8 -
Use
ease-in-outtiming function.p9 -
Apply the value of
select.speedto the animation's speed.p10 -
Hide the
.play-icon, and unhide the.pause-iconwithin this control.p11
When the animation is done:p12
-
Place the scrollbar thumb at the bottom by scrolling the viewports to their end.p13
-
Remove translation data that comes with simulating scrolling the mockups to keep the mockup ends to the viewport ends.p14
-
Unveil the scrollbar thumb.p15
-
Hide
.pause-icon, and unhide.play-icon.p16 -
Disable
button.stopsince there's no animation to stop.p17If there's already a focus on
button.stopcontrol, transfer the focus tobutton.playcontrol but prevent scrolling to avoid any sudden jump when the root window has been scrolled.p18
-
-
-
Else if simulations are running:p19
-
Pause the mockup animations.p20
-
Hide
.pause-icon, and unhide.play-iconwithin thisbutton.playcontrol.p21
-
-
Else if simulations are paused:p22
-
Capture the current time, to fix a bug later.p23
-
Play the mockup animations to resume.p24
-
Set the resumption time to the captured time, to avoid resuming from a previous frame if animation is not active on the normal speed.25
-
Unhide
.pause-icon, and hide.play-iconwithin thisbutton.playcontrol.p26
-
Stop Control
A click on button.stop control stops mockup animations as follows: r1
-
Pause the mockup animation, not cancel nor stop to query the current position.r2
-
Handover the mockup translation so far to the viewport scroll as follows:
-
Set the scroll top of the viewports to the exact vertical translation where their mockup was paused.r3
-
Cancel all mockup animations to clear their translation data.r4
-
-
Unveil the scrollbar of the viewports, unhide
.play-icon, hide.pause-icon, disablebutton.stop, and focus onbutton.scroll.r4
Also, do the above process when the browser emulator changes it size, so that changes in .tab viewports doesn't alter the current animation's keyframes which were based on the previous viewports, and cannot be modified on the fly.m5