Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript/css in IE8
    primarykey
    data
    text
    <p>Issue I am having is rotating an image (clock hands to be precise) in IE. The script below works to an extent (there is actually animation going on) but it's rotating completely off axis.</p> <p>I am by no means a wiz with Javascript/Jquery and am a bit lost when it comes to working out how to do this properly in IE8.</p> <p>Code below:</p> <pre><code>(function(jQuery) { jQuery.fn.clock = function(options) { var defaults = { offset: '+0', type: 'analog' }; var _this = this; var opts = jQuery.extend(defaults, options); setInterval( function() { var seconds = jQuery.calcTime(opts.offset).getSeconds(); if(opts.type=='analog') { var sdegree = seconds * 6; var srotate = "rotate(" + sdegree + "deg)"; var rad = Math.PI/180 * sdegree, cos = Math.cos(rad), sin = Math.sin(rad); jQuery(_this).find(".sec").css({"-moz-transform" : srotate, "-webkit-transform" : srotate, "-ms-transform" : srotate, 'filter': "progid:DXImageTransform.Microsoft.Matrix(M11="+cos+", M12="+(-sin)+", M21="+sin+", M22="+cos+", SizingMethod='auto expand')"}); } else { jQuery(_this).find(".sec").html(seconds); } }, 1000 ); setInterval( function() { var hours = jQuery.calcTime(opts.offset).getHours(); var mins = jQuery.calcTime(opts.offset).getMinutes(); if(opts.type=='analog') { var hdegree = hours * 30 + (mins / 2); var hrotate = "rotate(" + hdegree + "deg)"; var rad = Math.PI/180 * hdegree, cos = Math.cos(rad), sin = Math.sin(rad); jQuery(_this).find(".hour").css({"-moz-transform" : hrotate, "-webkit-transform" : hrotate, "-ms-transform" : hrotate, 'filter': "progid:DXImageTransform.Microsoft.Matrix(M11="+cos+", M12="+(-sin)+", M21="+sin+", M22="+cos+", SizingMethod='auto expand')"}); } else { jQuery(_this).find(".hour").html(hours+':'); } var meridiem = hours&lt;12?'AM':'PM'; jQuery(_this).find('.meridiem').html(meridiem); }, 1000 ); setInterval( function() { var mins = jQuery.calcTime(opts.offset).getMinutes(); if(opts.type=='analog') { var mdegree = mins * 6; var mrotate = "rotate(" + mdegree + "deg)"; var rad = Math.PI/180 * mdegree, cos = Math.cos(rad), sin = Math.sin(rad); jQuery(_this).find(".min").css({"-moz-transform" : mrotate, "-webkit-transform" : mrotate, "-ms-transform" : mrotate, 'filter': "progid:DXImageTransform.Microsoft.Matrix(M11="+cos+", M12="+(-sin)+", M21="+sin+", M22="+cos+", SizingMethod='auto expand')"}); } else { jQuery(_this).find(".min").html(mins+':'); } }, 1000 ); } })(jQuery); jQuery.calcTime = function(offset) { d = new Date(); utc = d.getTime() + (d.getTimezoneOffset() * 60000); nd = new Date(utc + (3600000*offset)); return nd; }; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload