Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
click on a site to add a new image in Squarespace? with Javascript?

I am tying to implement a code I got from a superhi tutorial on a squarespace site. I want to have a gallery that doesn't appear until you click. Like this site - studio-push.com

I have the script written - just not sure how to implement it in squarespace..... any ideas?

    // JavaScript to reveal image on click. 

const images = [
    "Folio-1.jpg",
    "Folio-2.jpg",
    "Folio-3.jpg"
]

let i = 0 

function placeImage(x, y){
    
    const nextImage = images[i]
    const img = document.createImage("img")
    img.setAttribute("src", nextImage)
    img.style.left = x + "px"
    img.style.top = y + "px"
    
    
    // if you want to rotate...
    //img.style.transform = "rotate (" + (Math.random() * 20 - 10) + "deg)"
    
    img.style.transform = "translate(-50%,-50%) scale(0.5)"
    
    document.body.appendChild(img) 
    
    i = i + 1
    
    if (i >= images.length) {
        i = 0 
    }
    
}

document.addEventListener("click", function(event){
    
    event.preventDefault()
    placeImage(event.pageX,event.pageY )
    
})


///on mobile 

document.addEventListener("touchend", function(event){
    
    event.preventDefault()
    placeImage(event.pageX,event.pageY )
    
})

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!