Animating with Jquery swipe motion

I am looking to make my brand image appear animated when the site is opened. I want it to swipe or move linearly from left to right and then return to its original position. I tried searching on Google for a solution but couldn't figure out how to make this function work.

Answer №1

Though you requested JQuery, it may not be necessary anymore for these types of animations with the availability of CSS animations. Utilizing CSS animations can offer a benefit to all users, even those who have disabled JavaScript or are in a corporate setting where it is restricted.

I've made modifications to a JSFiddle example originally using JQuery to demonstrate a logo div moving from left to right: http://jsfiddle.net/ny7pxe7y/

UPDATE: It has been noted that animating using left/right/top/bottom properties can impact performance on mobile devices. For optimal performance, consider utilizing CSS transforms instead. I have adjusted the values using transform: translateX(values); showcased here: http://jsfiddle.net/ny7pxe7y/5/ (This updated example uses viewport width units [vw])

HTML:

<div id="logo" class="demoStyle">LOGO</div>

CSS:

#logo {
  position: absolute;
  top: 0;
  left: 100%;
  -webkit-animation: slide 1.5s forwards;
  -webkit-animation-delay: 0.5s;
  animation: slide 1.5s forwards;
  animation-delay: 0.5s;
}

.demoStyle {
  line-height: 50px;
  display: block;
  background: yellow;
  width: 3em;
  height: 50px;
}

@-webkit-keyframes slide {
  100% { left: 0%; }
  75% { left: 100%; }
  50% { left: 0% }
  25% { left: 100%; }
  0% { left: 0% }
}

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

Is there a way to trigger an event once the ajax content has been fully loaded into a div with jQuery?

I have been working on a project that involves creating a scrolling feed content. I have managed to display the feed content inside a div successfully. However, I am facing an issue where each feed item needs to scroll individually. To achieve this, I trie ...

How to reposition the Bootstrap navbar Logo from the left to the center

I am looking to change the ordering of Bootstrap 4 Navbar. Currently, the logo is on the left side, but I want it in the center with menus on both sides. Can someone help me with changing this order? Check out the current Navbar layout below: <nav c ...

Tips for organizing nested form rows with Bootstrap 4

I am currently working on a nested form row and I am looking to align the form fields vertically. The current output I am getting is shown below: https://i.sstatic.net/NEWGY.png Here is the code snippet: <link rel="stylesheet" href="https://maxcdn ...

What could be causing my dropdown menu to vanish unexpectedly after being clicked for the first time?

To view the live demonstration, simply click here. I have an issue with my drop down menu where it is hidden upon first click. Additionally, I would like the drop down menu to disappear when clicked anywhere outside of its current display. How can I accomp ...

Exploring the Spotify API with jQuery/ajax to fetch details about songs, artists, and albums

I've been researching and have come across some information that is somewhat similar, but I'm still struggling to completely understand how this process works. My goal is to make a request to the Spotify API using jQuery to search for an artist ...

dealing with the presentation of options in linked drop-down menus, within an HTML context

Firstly, I apologize for my poorly phrased question. In the process of building a location-based application with Drupal. I have implemented a form that allows users to select their location. The form includes three 'dependent' select elements ...

Switching effortlessly between Fixed and Relative positioning

As I work on creating a unique scrolling experience, I aim to have elements stop at specific points and animate before returning to normal scroll behavior once the user reaches the final point of the page. Essentially, when div X reaches the middle of the ...

Triggering jQuery accordion when clicked

I have a challenge to tackle - I want to create an accordion system that can display and hide quotes at various points on the page. My desired outcome is to have one quote displayed per accordion panel. When I expand an accordion, I want to show the cont ...

Responsive height using Material Design Lite

I have a website using MDL, with a prominent header centered on the page. To enhance visibility, I added a background box behind the text. To view the CodePen example, click here. The challenge is to ensure that when the window is resized, such as on a m ...

Tips for aligning Picture boxes using CSS

As a newbie, I recently received training in HTML, CSS, and a bit of JavaScript. Currently, I am involved in a project where I display the latest news from an API. The technical aspects of fetching data from the API using JavaScript are handled by a senior ...

ASP.Net Core Razor: Troubleshooting Null JSON Value in Ajax Requests

I am currently using .Net Core Razor for my application and encountering an issue with passing values to the controller when calling the action from Ajax. Below is the script I am using: var table = $('#dataTable').DataTable(); var data = table. ...

Error occurs when SRCSET loads the wrong size because "sizes" parameter is missing

According to the guidelines, when sizes is not specified in the image attribute, the browser should automatically calculate the required size based on CSS rendering. In this scenario, my image is 300px and the browser should select the 300px image. Howeve ...

Saving the output of an AngularJS expression in an input field

Looking at the calculations below, I am currently evaluating an expression, {{ annualIncome * 4.5 }}, in one input and then re-evaluating the same expression in another input. Instead of saving the result and transferring it to the other input, I am repeat ...

My jQuery AJAX request is not successfully communicating with my PHP script

I am not well-versed in AJAX (or jQuery), but I believed my task was fairly straightforward. However, when attempting to send an AJAX request using: $.ajax( requestObj ); it seems to fail, and I am seeking assistance. To provide context, here is how the ...

Using jQuery to dynamically populate select options based on JSON data

I have been testing and searching for a solution to my issue, but it still doesn't work. Any help would be greatly appreciated. I have three select options implemented in PHP like this: <div class="control-group" id="merkPrinter"> <label cl ...

Ideas for displaying data or a message only once when selecting multiple checkboxes in jquery

code: <script> $(document).ready(function(){ $(".choose").click(function(){ job_type = $(':checked').map(function() { return this.value; }).get().join(',&ap ...

Pass a variable value as a parameter to a jQuery function using code-behind

Within my code behind, I am retrieving the [IDphoto] from an SQL database. My goal now is to pass this IDphoto as a parameter to a jQuery function upon onClick. How can I achieve this? Code behind sb.AppendFormat("<a onclick='popup()' href=& ...

C# MVC alert platform

Currently developing a C# MVC 4 app and aiming to integrate a notification system similar to Facebook's. I am considering implementing a table for each event to store notifications, then using AJAX calls every minute to fetch notifications for the cu ...

Animated CSS image swap triggered by hovering over and moving away from an element

I just started learning about jQuery yesterday, so I'm struggling a bit. But I have an idea in mind - I want to swap the image of my logo when the mouse hovers over it. Here's the code I've come up with so far, although I know it's not ...

Creating a Show/Hide toggle feature in AngularJS using NG-Repeat

I'm facing an issue with my code where I have a list of items that should only open one item at a time when clicked. However, currently, all items are opening on click and closing on the second click. Can anyone help me identify the problem in my code ...