Progressive zoom effect applied to an image in a JavaScript slideshow

Can someone assist me in replicating the zooming effect demonstrated in this code snippet:

`http://codepen.io/docode/pen/EjyVQY`. 

I am specifically focusing on the zooming feature of this slideshow. How can I replicate this zooming effect in JS rather than CSS? It's important to note that I want the zooming to happen automatically, without the need for a click or other event handler.

Thank you for any guidance you can provide! :)

UPDATE: The zooming effect should maintain the same width and height...

Answer №1

Code Snippet:

<div id="slideshow">
  <img src="http://docode.com.ua/wp-content/uploads/pictures/pic-3.jpg"/>
  <img src="http://docode.com.ua/wp-content/uploads/pictures/pic-2.jpg"/>    
  <img src="http://docode.com.ua/wp-content/uploads/pictures/pic-1.jpg"/>    
</div>

CSS Styles:

#slideshow {
  width:100%;
  height:100%;
  position:fixed;
}

#slideshow img {
  width:100%;
  height:100%;
  display:block;
  left:0;
  top:0;
  position:absolute;
  opacity:0;
}

JQuery Script:

images = $('#slideshow img');

i = 0;
animateImage(i);
setInterval(function() {
  if (i < images.length - 1) {
    i++;
  } else {
    i = 0;
  }
  animateImage(i);
}, 15000);

function animateImage(i) {
  $(images).eq(i).fadeTo(100, 0.8);
  $(images).eq(i).animate({
    width: '150%',
    height: '150%',
    top: '-25%',
    left: '-25%',
    opacity: 1
  }, 15000, "linear", function() {
    $(this).fadeTo(1000, 0, function() {
      $(this).css('width', '100%');
      $(this).css('height', '100%');
      $(this).css('top', '0');
      $(this).css('left', '0');
    });
  });
}

Interactive Demo: Try out the demo here. Feel free to adjust the values, speed, and animations to customize the slideshow. It can be displayed in full screen or within a container on a webpage.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with Jquery Ajax

Hey there, I've run into a bit of a snag and am in need of some guidance. My current issue involves trying to parse an XML file by utilizing JQuery's .ajax function. Below is the code snippet in question: The code above is saved in a test.js fil ...

Ways to display additional text with a "Read More" link after three lines of content without relying on a

I am currently working on an application where I need to display text in a limited space of 3 lines. If the text exceeds this limit, I want to show either "Read More" or "Hide". Below is the code snippet that I am using for this functionality. class Cust ...

Retrieving data from NodeJS ExpressJS variables

Hey fellow developers, Currently, I'm working with Express and Ajax to transfer data from the client to NodeJS. I am struggling with a situation where my variable seems to be undefined outside of the function. I would really appreciate it if someone ...

Populate the auto complete input box with items from a JSON encoded array

I have a PHP file that returns a JSON encoded array. I want to display the items from this JSON array in an autocomplete search box. In my search3.php file, I have the following code: <?php include 'db_connect.php'; $link = mysqli_connect($ho ...

I'm encountering an error when trying to return a value using the question mark operator in Vue.js - can someone explain why

When I attempted to retrieve the value using the question mark operator instead of using return twice, I encountered an error stating "Cannot read property 'omitDescription' of undefined." buttonText() { return this.omitDescription ? 'プ ...

Sorting Angular components in reverse alphabetical order from A to Z

I feel like the answer to this problem is staring me right in the face, but no matter how hard I look, I just can't seem to find it. When dealing with a large ng-repeat, I have multiple sort options that I pass as an array. The user has the ability t ...

What could be the reason for my mongoose model failing to save in mongodb?

I am experiencing an issue with my simple Post model and route for creating posts. After submitting a new post using Postman, the request hangs for a moment before returning an error in JSON format. The model data is never saved successfully. Below is the ...

Exploring and extracting values from nested arrays of objects in JavaScript and React

Hey there, I am having trouble getting the data from the backend server to display on a chart library. Can you please take a look at my code and help me out? const data = [ { id: "americano", data: [{x: "10",y: 10,}, {x: &quo ...

Exploring the JSON data received from PHP script via jQuery AJAX

In my program, I have created a web page with 5 radio buttons for selection. The goal is to change the picture displayed below the buttons each time a different button is chosen. However, I am encountering an issue during the JSON decoding phase after rec ...

Internet Explorer fails to execute CSS or jQuery commands

Apologies in advance for posing a question that may not be specific or beneficial to the wider community. Currently, my main focus is resolving this issue for my own peace of mind. In the process of designing a website, I implemented a social drawer featu ...

Moment.js generated an error due to an unhandled promise rejection warning

I'm trying to determine if my current timestamp is equal or greater than a certain value, but I keep encountering errors. Here's my code with the error: {...} exports.validaforgotpass = async (req, res) => { {...} const results = aw ...

Converting a table-based layout to Bootstrap using the "row" and "col-*-*" classes

My current project is built on a table-layout structure, but now the requirements have changed and we need to make it responsive. To achieve this, we have decided to use Bootstrap. How can I convert the existing tables into a Bootstrap grid layout without ...

Create a system where three arrays are interconnected, with the first array representing the name of the object

I have a group of different objects structured like this: let object1 = { xyz: 'xyz1', arr: [] }, object2 = { xyz: 'xyz2', arr: [] }, object3 = { xyz: 'xyz3', arr: [] } Manag ...

Having trouble loading xml/xsl files on IE11? Consider enabling compatibility mode to ensure smooth rendering on your xml/xsl page

On my website, I have a page that displays XML from an XSL document. Strangely, it works perfectly on IE8 but not on IE11 - the page appears blank even though the XML is present when viewing the source. Interestingly, if I enable compatibility mode for the ...

Determine the position of an element in relation to a specific ancestor using JavaScript

Let's consider the following example of HTML code: <div id="site_header_container" class="site_bar_container"> <div id="site_header"> <div id="header_logo_container"> <a class="sliced" id="header_ ...

Make a portion of the title come alive on hover

Looking to add animation to a title that consists of two parts: "HARD" and "WARE", with the second part having a more transparent color. When hovering over the "HARD" word, the colors reverse correctly. However, when hovering over the "WARE" word, only on ...

The background of the ACTK Modal Popup vanishes after multiple instances of scrolling up and down

The issue I'm facing is with the AJAX Control ToolKit Modal Popup's background (the blind curtain) disappearing after scrolling up and down several times. I have attempted to resolve this by applying various CSS styles, but unfortunately, none of ...

What is the best way to position href text on the top of a rectangular div box?

Whenever I try to position the text above the rectangle, it disables the link. How can I resolve this issue? Additionally, when attempting to change the color of the "San Diego" text, I'm unable to adjust its position. Just a heads up, I am new to HT ...

Deselect the checkbox that was initially selected when an alternative checkbox option has been chosen

I am trying to implement a feature where there are 2 groups of checkbox options on the same page. Below is the code snippet: <div class="col-xs-12"> <label class="checkbox-inline"> <input type="checkbox" th:field="*{borrowerRace1}" th:val ...

Choosing multiple options from a list

I am working on a messaging app where users can compose and send messages to contacts. Currently, I am only able to send messages to one contact at a time. My goal is to enable users to select multiple contacts to create group messages. Since I am new to a ...