- Go to your Online store > Themes > Actions > Edit code
- Go to Section folder and open the main-product.liquid
- Find <slider-component> block and comment it out or delete it if you want
Comment it out by placing “<!--” before the slider-component and “-->” after the slider-component. Code should look like below
4. Before the commented out <slider-component>, add the code below
5. On the top part, paste the code below, and click SAVE
6. I see that the component-slider.css is also being use for multi-column section, therefore, we have to create a new .css file. Go to Asset folder, click 'create new asset', create blank. Name the file 'product-slider'. File should show like below
7. Now open, the created CSS folder and paste the code below.
8. Next, go back to the main-product.liquid. At the top part, comment out this code. You can also just delete it. To comment it out, place (<!-- ) before the code and (--->) after. Just like we did in the slider-component. Code should look like this.
add this after.
9. We need to go to the Asset folder again, and open global.js. Find the slider-component. Since slider component is a global code, meaning, some section also uses the same code. We have to add an if statement. Please disregard the video regarding this section in global.js.
At the SliderComponent constructor add the code below.
10. At the initPages function we need to change the totalPages. Replace the code below:
with this
11. Lastly, at the update function we need to change the currentPage, change the 1 into 4. Replace the code below, and click SAVE
to this
The global.js code should look like this:
That's it! You just transform the product page of Dawn theme. Let me know if you have questions or having issues with the code so we can fix it and have an updated code. (",)
Update 09/22/21: I end up changing the the code in the Asset/global.js so we do not break the slider component if we use it in the other section
I change the CSS code and remove the resize observer. Large-image will be the same height with the large-image-item.
Update 09/23/21: Issues of having two large image and slider missing fixed. Updated code to use feature hide_variants
Update 09/25/21: Fix the issue with thumbnail disappears when adding a section that uses a slider-component. Updated the code in the step #4.
Update 09/26/21: Added a video play button when thumbnail image is a video
Update 09/30/21: Fix the issue regarding the video button. Reposition the codes for the video-btn and added some css codes
Update 10/01/21: Fix the issue of stacking large images in mobile. I added a resizeObserver in the Javascript to fix the issue of big gaps between the large-image and the slider. If you don't want it you just delete the code
Update 10/03/21: Added overflow: hidden to large-image css. I would recommend not to have product images with extreme height as your first variant image. Also added some CSS so when active, thumbnail image will have border box and opacity is 1. See code in green. Thumbnail border color is dependent on your var(--gradient-base-accent-1).
Update 10/04/21: Change the v-btn in the product-slider.css file due to issue when having a mobile video
Update 10/10/21: I know I fix the issue regarding the space between the large image and the slider. I did remove the resizeObserver and also the padding-bottom of the large image to fix this. I updated the code
Update 10/11/21: I change how the border and opacity is applied. Please see the highlighted green code
Update 10/15/21: I added an onload function so when the window loaded the first image in the thumbnail will get the active property. Code is pink.
Also added a code for those who still want the option to hide the variants when variants selected. (NOTE: this is the original code from Dawn). See code in blue.
Copied!
45 comments
will this code work for supply theme?
Hi everyone,
Just FYI. This code does not work if you have Dawn version 2.0 and higher. Shopify team already added this functionality in the newer version. Please check your theme editor
I have done all the steps. But slider is not coming. I can see images but arrow to slide next image is not working. Kindly advise
Hi,
Is it possible to add a slider buttons to the top image (main image) so the user doesn’t need to scroll down to see more images?
Thank you.
Andrei.
just saw you have put up an updated tutorial that seems to fix the issues, thanks! :)