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 8343191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:58:58+00:00 2026-06-09T05:58:58+00:00

My code : var transformString = Modernizr.prefixed(‘transform’); var inputDown, inputMove, inputUp; if (window.Touch) {

  • 0

My code:

var transformString = Modernizr.prefixed('transform');
var inputDown, inputMove, inputUp;


if (window.Touch) {
  inputDown = "touchstart";
  inputMove = "touchmove";
  inputUp = "touchend";
}
else {
  inputDown = "mousedown";
  inputMove = "mousemove";
  inputUp = "mouseup";
}

var mouse = { startX: 0, startY: 0 };
var innerElement = $('.threedee');

function normalizedX(event){
    return window.Touch ? event.originalEvent.touches[0].pageX : event.pageX;
}    

function normalizedY(event){
    return window.Touch ? event.originalEvent.touches[0].pageY : event.pageY;
}

$(document).bind(inputDown, function(event){
  event.preventDefault();
  if(event.button === 2) return true; // right-click
  mouse.startX = normalizedX(event);
  mouse.startY = normalizedY(event);
  // store the transform state
  // globalMatrix.setMatrixValue($inner.css('-webkit-transform'));
  $(document)
   .bind(inputMove, move)
   .one(inputUp, function(){ $(document).unbind(inputMove); });
});

function move(event){
  event.preventDefault();
  var offsetX = normalizedX(event) - mouse.startX;
  var offsetY = normalizedY(event) - mouse.startY;
  if(event.shiftKey){
   offsetX = roundToMultiple(offsetX, 15);
   offsetY = roundToMultiple(offsetY, 15);
  }
  innerElement.css(transformString, 'rotateY('+offsetX+'deg) rotateX('+-offsetY+'deg)');
  /* move relative to the initial position
  $inner.css('-webkit-transform', globalMatrix.rotate(-offsetY, offsetX, 0));//*/
}

function roundToMultiple(number, multiple){
  var value = number/multiple
  ,   integer = Math.floor(value)
  ,   rest = value - integer;
  return rest > 0.5 ? (integer+1)*multiple : integer*multiple;
}​

Try to look at the javascript part only, my problem is there.

I am wondering why the “event” will pass as parameter and argument for most of the function in the script. Sometime it may be “e” also. Who created them???

I myself never created any “event” variable, who is responsible for this “event” variable.

  • 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-09T05:59:00+00:00Added an answer on June 9, 2026 at 5:59 am

    jQuery will call your event function and it will pass an event object into the argument. You don’t need to worry about creating the variable, and you can give the argument any name you want (assuming it’s a valid variable name).

    The creation of the event object should be considered “black box”, and you shouldn’t worry about its exact structure or implementation. Just do what the docs and examples show you to do, and you’ll be all right.

    The key thing is to have a parameter in the function, though; otherwise, you won’t have access to the event object jQuery passes.

    As some other answers have stated, it’s probably a good idea to avoid the name event, because if you’re not careful you could conflict with a global variable of the same name on certain browsers. Instead, use e or similar and then you’ll get a NameError if you forget to have a parameter in your function.

    // Wrong way #1
    $('.class').bind('click', function() {
        event.preventDefault();    // may attempt to call .preventDefault() on window.event if it exists
    });
    
    // Wrong way #2 (fails fast since e probably won't be on the global object)
    $('.class').bind('click', function() {
        e.preventDefault();        // ReferenceError thrown here
    });
    
    // The correct way
    $('.class').bind('click', function(e) {    // or (event) if you want, but the first example can bite you
        e.preventDefault();        // no problem
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code: var result = db.rows.Take(30).ToList().Select(a => AMethod(a)); db.rows.Take(30) is Linq-To-SQL I am using ToList()
The code: var Appointment = Backbone.Model.extend({}); var appointment = new Appointment(); appointment.set('title', 'My knee
Sample Code: var Day = Ember.Object.extend({ date:null, activities:null, // is set to an Em.ArrayProxy
The code: var foo = /\</; When I go to jslint.com and enter that
This code var offset = $('#snapwrap_inner').offset(); alert(offset.left) in FF returns 0px but in Opera
My code: var parent = document.createElement('div'); var pen = document.createElement('div'); var dog = document.createElement('div');
I have the following code: var submitHandler = function ($link, $form, close) { var
I have this code: var query = _cityRepository.GetAll( u => u.PartitionKey == pk &
This is my code: var boo = new RegExp(\\Bis\\B,gi); var result = boo.exec(this AisA
I have the following code: var refreshId = setInterval(function() { $(#footad).html('myjshere'); }, 15500); Where

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.