Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8521775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:55:16+00:00 2026-06-11T06:55:16+00:00

Wonder if their is a cleaner way of structuring this code?? I was hoping

  • 0

Wonder if their is a cleaner way of structuring this code?? I was hoping to use data-attributes for the left and right values of the back and forward buttons.

THANKS!!!

.hover-area { position:relative; width:100%; height:50px; }
.backward, .forward { position:absolute; }
.backward{ left:0px; }
.forward { right:0px; }​

<div class="hover-area">
  Hover Area
  <div class="backward" data-animate-on='{"left":"20"}' data-animate-off='{"left":"0"}'>
    Previous
  </div>
  <div class="forward" data-animate-on='{"right":"20"}' data-animate-off='{"right":"0"}'>
    Next
  </div>
</div>

 $('.forward').css({
     opacity: 0,
     right: 0
 });
 $('.hover-area').hover(function () {
     $(this).find('.forward').stop().animate({
         right: 20
     }, {
         queue: false,
         duration: 300,
         easing: 'easeOutCubic'
     }).animate({
         opacity: '0.95'
     }, {
         queue: false,
         duration: 400,
         easing: 'easeOutCubic'
     });
 }, function () {
     $(this).find('.forward').stop().animate({
         right: 0
     }, {
         queue: false,
         duration: 550,
         easing: 'easeOutSine'
     }).animate({
         opacity: '0'
     }, {
         queue: false,
         duration: 300,
         easing: 'easeOutSine'
     });
 });

 $('.backward').css({
     opacity: 0,
     left: 0
 });
 $('.hover-area').hover(function () {
     $(this).find('.backward').stop().animate({
         left: 20
     }, {
         queue: false,
         duration: 300,
         easing: 'easeOutCubic'
     }).animate({
         opacity: '0.95'
     }, {
         queue: false,
         duration: 400,
         easing: 'easeOutCubic'
     });
 }, function () {
     $(this).find('.backward').stop().animate({
         left: 0
     }, {
         queue: false,
         duration: 550,
         easing: 'easeOutSine'
     }).animate({
         opacity: '0'
     }, {
         queue: false,
         duration: 300,
         easing: 'easeOutSine'
     });
 });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:55:17+00:00Added an answer on June 11, 2026 at 6:55 am
    1. You can combine your functions and run them together.
    2. Then you can store similar config of animation in variables and use them then.
    3. To get info of animation you can use just $(el).data('animate-on'), it will return object.
    4. Also you can use jQuery.each, because what you do with buttons are very similar.

    .Demo: http://jsfiddle.net/vYvVb/1/

    $('.forward').css({ opacity: 0, right: 0 });
    $('.backward').css({ opacity: 0, left: 0 });
    
    $('.hover-area').hover(function () {
      var conf_1 = { queue: false, duration: 300, easing: 'easeOutCubic' };
      var conf_2 = { queue: false, duration: 400, easing: 'easeOutCubic' };
    
      $(this).find('.backward, .forward').each(function () {
        $(this).stop()
          .animate($(this).data('animate-on'), conf_1)
          .animate({ opacity: 0.95 }, conf_2);
      });
    }, function() {
      var conf_1 = { queue: false, duration: 550, easing: 'easeOutSine' };
      var conf_2 = { queue: false, duration: 300, easing: 'easeOutSine' };
    
      $(this).find('.backward, .forward').each(function () {
        $(this).stop()
          .animate($(this).data('animate-off'), conf_1)
          .animate({ opacity: 0 }, conf_2);
      });
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder if anyone could offer their advice on this one. I have some
I just wonder what asp.net datagrid does Microsoft use in their website? For example,
I wonder what is the proper way to get back some message from a
wonder if I could get some advice on the best way to solve this
i'm working on a large c# project,i wonder why people use DLLs in their
i wonder if there is a way to change the use audio port for
I wonder if someone can point me into the right direction on this. When
I wonder how many users still have not upgraded their phones from version 2.2.1.
wonder if someone could help me with a little problem. I have session values
In ruby on rails 3 you can use their ActiveMailer for sending emails. Also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.