Monday, January 23, 2017

Product Quick View

Product Quick View

A 'product quick view' modal window, animated using CSS3 and Velocity.js, that provides the user a quick access to the main product information.
Browser support
  • ie
  •  
  • Chrome
  •  
  • Firefox
  •  
  • Safari
  •  
  • Opera
9+
There are some patterns in the e-commerce design world aimed at increasing the conversion rate by simplifying the user experience. Other patterns try to achieve the same goal by providing additional information where needed. The product quick view modal belongs to the second category.
The standard process is straightforward: click on the quick view button to fire a modal with additional information and a call-to-action button. By building our resource, we didn’t reinvent the wheel: at the end you still get the same result. We tried to enhance the transition from point A to point B though.
These days native applications are using the full power of the device and motion design notions to provide the best UX possible. The web needs to run at the same speed. There are great tools like Bounce.js by Joel Besada and Velocity.js by Julian Shapiro that can help you build smooth animations.
Getting back to our nugget, here is a quick animation to show you what we had in mind (.gif created in After Effects):
product quick view animation

Creating the structure

The gallery is an unordered list. The cool stuff happens into the .cd-quick-view <div>, which contains a slider (.cd-slider-wrapper) and the product information (.cd-item-info).

Adding style

First of all, the quick view effect is hidden on small devices. The reason being that on a phone it’s easier to access directly the product page.
That said, most of the animations have been created in jQuery using Velocity.js to avoid jank effects. The dark overlay layer was created by animating the body::after pseudo-element:
A lot of elements are animated or have a CSS3 transition. To keep a good performance we used the translateZ(0) hack on some of them (while we wait for the new will-change property to get more browser support).
No more CSS tricks worth mentioning. Let’s dive into jQuery!

Events handling

When user clicks the .cd-trigger element, we evaluate the top, left and width values of the gallery selected image and assign them to the .cd-quick-view element (which is in position: fixed). This way the .cd-quick-view has the same dimensions of the gallery image and completely covers it (meanwhile the gallery image is hidden using the .empty-box class).
We then animate the .cd-quick-view element. First step we animate the .cd-quick-view width to the sliderFinalWidth (this is a variable set to 400 in the .js file). This value represents the width of the slider image inside the quick view panel; we also animate the .cd-quick-view position (top and left values) so that it’s centered in the viewport (the height of the quick view panel is automatically given by the image slider height). Note that during this step, only the image slider is visible, while the rest of the quick view content is hidden.
Second step we change the .cd-quick-view width to its final value ( 80% of the viewport width, with a max value of 900 – defined by the maxQuickWidth variable) and change its position accordingly so that the panel is always centered.
After this second step, we assign the .add-content class to the .cd-quick-view to show its hidden content.
For the animation, we used Velocity.js, a plugin that re-implements jQuery’s $.animate() for significantly greater performance (if you’ve never used it, you should definitively give it a try!). We used the ‘spring’ easing for the first animation step, and the ‘ease’ for the second one.
When user closes the quick view panel, the reverse animation is performed (in this case, ‘ease’ is used for both animations).
One additional note: before closing the quick view panel, we update the galley image src value, this way it’s equal to the slider visible image.
source : https://codyhouse.co/gem/css-product-quick-view/
download : https://codyhouse.co/redirect/?resource=product-quick-view

No comments:

Post a Comment