Seamless blend of images with a stunning mosaic transition effect

I attempted to create a mosaic effect on my carousel

similar to this example:

, but not exactly like this. I want to include control buttons for next and previous, and have images in HTML tag.

However, my attempt is not working and I need help.

This is my work: Jsfiddle

I have only created the next button, for the previous button it will be similar except I will replace position++ with position--

Jquery Code:

$(function(){
  var $carroussel = $('#carrousel'); 
    var $carrousselhover = $('#carrousel .hover');
    $carroussel.append('<div class="controls"> <span class="Previous"> <img src="http://s27.postimg.org/ip6n42rn3/previous.png"> </span> <span  class="Next"> <img src="http://s27.postimg.org/6yspmoyun/next.png"> </span></div>');

var $nbrimage = $('#carrousel img').length - 1;
    var $img = $('#carrousel img');

   var width = 700;
var height = 200;
 var horizontal_pieces = 8;
    var vertical_pieces = 6;
    total_pieces = horizontal_pieces * vertical_pieces;

    var box_width = width / horizontal_pieces;
    var box_height = height / vertical_pieces;
    var vertical_position = 0;
elements = new Array();
var count ;
count = 0;
    var $position;
    $position = 0;
    $carroussel.width(width).height(height);
    var $currentImage = $img.eq($position); // First image

    var listimage = $('#carrousel ul li');
    var tempEl;
  $('.controls .Next').click(function(){

      if($position < $nbrimage)
      {

          for (i = 0; i < total_pieces; i++)
    {
        $currentImage = $img.eq($position);
         tempEl = $('<span class="hover" id="hover-' + i + '"></span>');

        var horizontal_position = (i % horizontal_pieces) * box_width;

        if(i > 0 && i % horizontal_pieces == 0)
        {
            vertical_position += box_height;
        }

        tempEl.css({'background-position': '-' + horizontal_position + 'px -' + vertical_position + 'px',

                   'background-image': 'url('+$img.eq($position).attr('src')+')'});
        $img.eq($position).remove();
        listimage.eq($position).append(tempEl);
        elements.push(tempEl);
    }

       $position++;
      $carroussel.css({'background-image': 'url('+$img.eq($position).attr('src')+')'});
          $('#carrousel .hover').width(box_width).height(box_height);
         setInterval(toggleDisplay,10000);

      }
      else
      {
          $position = $nbrimage;
      }
       function toggleDisplay()
{
if(count >= total_pieces)
{
    clearInterval(0);


}
    else
    {
    var tempEl = elements[count];
    var opacity = tempEl.css('opacity');

    if(opacity == 0)
    {
        tempEl.animate({ opacity: 1 })
    }
    else
    {
        tempEl.animate({ opacity: 0 })
    }

    count = (count + 1);
    }


}
  });


});

Css Code:

#carrousel{
    position:relative;

    margin:0 auto;
    z-index:2;
}
#carrousel ul li{
    position:absolute;
top:0px;
    left:0px;
    list-style-type:none;
}
#carrousel .hover{
}
.controls
{
position:relative;
    height:200px;
    width:700px;
    margin:0 auto;
    z-index:1;

}

.controls .Next {
position:absolute;
right:4px;
top:30px;
}

.controls .Previous{
position:absolute;
left:4px;
top:30px;
}

.controls span:hover
{

cursor:pointer;

}

Answer №1

One creative solution could be to break the desired image into smaller sections, using a tool like Photoshop. Then, you can animate these segments to come together and reveal the full picture.

I hope this suggestion proves to be helpful for your project! :)

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

jquery.event.drag - Execute code for each increment of X pixels dragged

Currently, I am utilizing jquery.event.drag.js for a project I am developing. My goal is to execute a script after every interval of X pixels dragged along the X axis. Below is a snippet of the code I have implemented. $('body').drag(function( e ...

Storing the current URL in the controller prior to leaving the page

Due to certain requirements, I need to save the URL of the page that the user is leaving in order to use it in other views and controllers. For example, if the user is currently on www.page1.com and is navigating to www.page2.com, I want to somehow save th ...

How can I display a nested div when the parent div's v-if condition is not met?

In my project, I am utilizing Laravel 6 in combination with Vue.js 2. To iterate through users and showcase their information within div elements, I am using a for loop outlined below. The Category names are stored in user.pivot.demo2, and the users are ...

Leveraging Polymer web components without the need for a package manager

I am looking to incorporate web components into a static web page without the need for any package manager or JavaScript build process. After referencing , I attempted to import them using unpkg by changing <script type="module" src="node_modules/@pol ...

Creating a large and spacious modal in Angular using ngx-bootstrap

I need help with resizing the ngx-modal to cover a large area of the screen. Currently, I am trying to make it so that when something is clicked, the modal should overlay an 80% width grid on a full desktop screen. Despite my attempts at using .modal-xl an ...

Utilizing a responsive design with a bootstrap grid system, featuring expandable columns for

After creating a bootstrap grid page, I am facing an issue with the layout on mobile screens. My problem arises when trying to reorder the cards properly for mobile view. Here is my current logic: <div class="row"> <div *ngFor="let col of [1, ...

Get rid of the lower padding on a handsontable

I am currently using either Chrome Version 61.0.3163.100 (Official Build) (64-bit) or Safari Version 11.0 (12604.1.38.1.7) on Mac OS Sierra 10.12.6. I am looking to create a handsontable that may exceed the screen height: Click here for an example As I ...

Utilizing Jquery.Cycle with IE7 for transitioning to the next div element

Looking for assistance with a perplexing issue involving Jquery.cycle. I integrated jQuery.cycle (version 2.72) into an existing application (Prestashop) to create a slideshow of images. It works perfectly on Firefox and Mozilla, but encounters a strange ...

Can you explain the distinction in jQuery between these two types of $.each statements?

I've had experience with both methods in the past but I'm uncertain about their distinctions. Can someone clarify the variances between them? 1. $(myObjects).each(function(){}}; 2. $.each($(myObjects), function(){}); ...

Problems with Wordpress AJAX search functionality

I am currently working on implementing a search feature using AJAX to dynamically load posts. However, I am facing an issue where the results are not being displayed. This code snippet was adapted from another source and modified based on private feedback ...

The current context does not have a reference to TextBox

I am encountering an issue with my simple aspx page. Despite not using Master Content Page, I am seeing the following error: The name 'txtFirstName' does not exist in the current context Here is my Markup: <%@ Page Language="C#" %> &l ...

The getText method in Selenium seems to be malfunctioning as it is unable to retrieve any text content from

Struggling to capture the text of WebElement using two different methods, but both are returning blank strings. // Method 1 d.findElement(By.id("deliveryDate")).getTex(); // Method 2 WebElement deliveryDate = d.findElement(By.id("deliveryDate")); Sys ...

When using ViewBag in JavaScript, an error may occur with the message "Uncaught SyntaxError: Unexpected token '<'"

When I try to fetch data from an API and assign it to the VIEW BAG, I encounter an error during runtime. List<DevInfo> DevList = await RestApi.Instance.GetAllDevAsync(); var nameT = DevList.Select(a=>a.Name).ToList(); ViewBag.datasourceDevList = n ...

JavaScript/DOM - What sets apart a "CSS Selector" from an attribute?

When it comes to excluding declarative event handlers: <a href='#' onclick=<handler> ... /> Is there a significant difference between an Attribute and a CSS Selector? For example, if I define my own attribute: <a href='#&a ...

Top method for showcasing animated images (HTML/CSS/JS)

For my website, I want to create an engaging animation showing a coin being flipped multiple times in the air before landing on a specific side. After the animation finishes, I would like it to transform into a static image of the final result. I've ...

Algorithm for detecting collisions in Javascript

I am looking to implement a collision detection function in JavaScript for canvas. Specifically, I have coin and piggy bank objects and want to create a function that triggers the disappearance of a coin object when it comes into contact with a piggy bank. ...

The Bootstrap 3 Navbar displays a #EEEEEE color when a link is hovered over

I have not specified a hover color in the stylesheet for links to be #EEEEEE. I want the navbar hover effect to blend in with the navbar background, creating a seamless transition when hovered over. For reference, here is my current stylesheet code: Paste ...

Tips for customizing MUI PaperProps using styled components

I am trying to customize the width of the menu using styled components in MUI. Initially, I attempted the following: const StyledMenu = styled(Menu)` && { width: 100%; } `; However, this did not have any effect. After further research, I ...

Learn how to send dynamic data to another HTML element using Ajax's success function

I received a successful ajax response from one HTML file, but I'm struggling to dynamically set the data from this response to another HTML file. Can anyone help me with this issue? Here is the code snippet from my ajax report: success: function( ...

The feature of Jquery click and cursor: pointer only focuses on a single element at a

Recently, I created a navbar that includes a dropdown feature. I encountered an issue where I wanted the dropdown to show up when clicking on the navbar-profile class (which contains the profile picture, name, and chevron icon) in the top right corner. Ho ...