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-modal element, to hold a browser emulator in fullscreen mode when the modal is opened.

  • One or more .browser elements, the browser emulators, each with the following descendants:

    • One .tab-group element, with a data-track-key attribute specifying the animation data from the tracks parameter to be used for the mockups within the tab group.

      • One .tab.tab-one element, and, optionally, one .tab.tab-two element, acting as viewports.

        Each contains an img.mockup element for an unsplit mockup, or an svg.mockup element for a split mockup.

    • One button.size element, 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-target attribute to refer to another ancestor over the Browser Emulator to transport in and out of the fullscreen mode.

    • One button.play control element, containing two icons: an unhidden .play-icon, and a hidden .pause-icon, corresponding to the initial state of the mockups.

    • button.stop control element, disabled by default since mockups are not scrolling.

    • select.speed control 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:

  • tabGroup is the value of the data-track-key on the .tab-group within a browser emulator.

  • y1 and y2 are keyframes for the .mockup of .tab-one and .tab-two viewports 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.

  • duration is the no of seconds it must take both mockups to finish scrolling.

  • times provides 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

  1. Query the target whose ID is provided in the data-target on this control. If no ID, it defaults to the browser emulator itself.m2

  2. If dialog#fullscreen-modal is 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

  3. 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

  4. 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

  1. If no active mockup animation, do nothing, setting the value for the next time an animation will run.f2

  2. 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

  1. Enable button.stop to stop active simulations, be it running or paused simulation.p2

  2. Veil the scrollbar of each .tab viewport, to disallow any intervention while simulating the scrolling.p3

  3. If animation states of mockups are idle, as expected by default, scroll the viewports and translate the mockups as follows:p4

    1. Reset any manual scrolls by smoothly scrolling the viewports to the top, then force a delay of 250s before translating the mockups.p5

    2. Using the Motion Library, translate, vertically, the .mockup of .tab-one and .tab-two viewports based on the tracks data whose key is retrieved from the data-track-key of the mockups' .tab-group, with the following in mind:p6

      • For responsiveness of the keyframes, remap the items of y1 and y2 arrays such that their last item is the maximum scroll value of the current .tab viewport.p7

      • If times is not provided, maintain uniform speed on both mockups by generating a single timing, based on whichever of y1 and y2 has the greater last item.p8

      • Use ease-in-out timing function.p9

      • Apply the value of select.speed to the animation's speed.p10

      • Hide the .play-icon, and unhide the .pause-icon within 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.stop since there's no animation to stop.p17

        If there's already a focus on button.stop control, transfer the focus to button.play control but prevent scrolling to avoid any sudden jump when the root window has been scrolled.p18

  4. Else if simulations are running:p19

    • Pause the mockup animations.p20

    • Hide .pause-icon, and unhide .play-icon within this button.play control.p21

  5. 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-icon within this button.play control.p26

Stop Control

A click on button.stop control stops mockup animations as follows: r1

  1. Pause the mockup animation, not cancel nor stop to query the current position.r2

  2. Handover the mockup translation so far to the viewport scroll as follows:

    1. Set the scroll top of the viewports to the exact vertical translation where their mockup was paused.r3

    2. Cancel all mockup animations to clear their translation data.r4

  3. Unveil the scrollbar of the viewports, unhide .play-icon, hide .pause-icon, disable button.stop, and focus on button.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