EdgeExpressDB
view release on metacpan or search on metacpan
www/edgeexpress/jscript/SpryAssets/SpryEffects.js view on Meta::CPAN
dimensions.height = parseInt(element.style.height, 10); // without padding
else
{
if (!computedStyle)
computedStyle = Spry.Effect.getComputedStyle(element);
var tryComputedStyle = computedStyle && computedStyle.height && /px/i.test(computedStyle.height);
if (tryComputedStyle)
dimensions.height = parseInt(computedStyle.height, 10); // without padding, includes css
if(!tryComputedStyle || dimensions.height == 0) // otherwise we might run into problems on safari and opera (mac only)
dimensions.height = element.offsetHeight; // includes padding
}
return dimensions;
};
Spry.Effect.getDimensionsRegardlessOfDisplayState = function(element, displayElement)
{
// If the displayElement display property is set to 'none', we temporarily set its
// visibility state to 'hidden' to be able to calculate the dimension.
var refElement = displayElement ? displayElement : element;
var displayOrig = Spry.Effect.getStyleProp(refElement, 'display');
var visibilityOrig = Spry.Effect.getStyleProp(refElement, 'visibility');
if(displayOrig == 'none')
{
Spry.Effect.setStyleProp(refElement, 'visibility', 'hidden');
Spry.Effect.setStyleProp(refElement, 'display', 'block');
if(window.opera) // opera needs focus to calculate the size for hidden elements
refElement.focus();
}
var dimensions = Spry.Effect.getDimensions(element);
if(displayOrig == 'none') // reset the original values
{
Spry.Effect.setStyleProp(refElement, 'display', 'none');
Spry.Effect.setStyleProp(refElement, 'visibility', visibilityOrig);
}
return dimensions;
};
Spry.Effect.getOpacity = function(element)
{
var o = Spry.Effect.getStyleProp(element, "opacity");
if (typeof o == 'undefined' || o == null)
o = 1.0;
return o;
};
Spry.Effect.getBgColor = function(ele)
{
return Spry.Effect.getStyleProp(ele, "background-color");
};
Spry.Effect.intPropStyle = function(e, prop){
var i = parseInt(Spry.Effect.getStyleProp(e, prop), 10);
if (isNaN(i))
return 0;
return i;
};
Spry.Effect.getPosition = function(element)
{
var position = new Spry.Effect.Utils.Position;
var computedStyle = null;
if (element.style.left && /px/i.test(element.style.left))
position.x = parseInt(element.style.left, 10); // without padding
else
{
computedStyle = Spry.Effect.getComputedStyle(element);
var tryComputedStyle = computedStyle && computedStyle.left && /px/i.test(computedStyle.left);
if (tryComputedStyle)
position.x = parseInt(computedStyle.left, 10); // without padding, includes css
if(!tryComputedStyle || position.x == 0) // otherwise we might run into problems on safari and opera (mac only)
position.x = element.offsetLeft; // includes padding
}
if (element.style.top && /px/i.test(element.style.top))
position.y = parseInt(element.style.top, 10); // without padding
else
{
if (!computedStyle)
computedStyle = Spry.Effect.getComputedStyle(element);
var tryComputedStyle = computedStyle && computedStyle.top && /px/i.test(computedStyle.top);
if (tryComputedStyle)
position.y = parseInt(computedStyle.top, 10); // without padding, includes css
if(!tryComputedStyle || position.y == 0) // otherwise we might run into problems on safari and opera (mac only)
position.y = element.offsetTop; // includes padding
}
return position;
};
Spry.Effect.getOffsetPosition = Spry.Effect.getPosition; // deprecated
//////////////////////////////////////////////////////////////////////
//
// Spry.Effect.Animator
// (base class)
//
//////////////////////////////////////////////////////////////////////
Spry.Effect.Animator = function(options)
{
Spry.Utils.Notifier.call(this);
this.name = 'Animator';
this.element = null;
this.startMilliseconds = 0;
this.repeat = 'none';
this.isRunning = false;
this.timer = null;
www/edgeexpress/jscript/SpryAssets/SpryEffects.js view on Meta::CPAN
this.effectsArray[this.effectsArray.length] = new this.ClusteredEffect(effect, "queue");
if (this.effectsArray.length == 1)
{
// with the first added effect we know the element
// that the cluster is working on
this.element = effect.element;
}
};
Spry.Effect.Cluster.prototype.addParallelEffect = function(effect)
{
if (this.effectsArray.length == 0 || this.effectsArray[this.effectsArray.length-1].kind != 'parallel')
effect.addObserver(this);
this.effectsArray[this.effectsArray.length] = new this.ClusteredEffect(effect, "parallel");
if (this.effectsArray.length == 1)
{
// with the first added effect we know the element
// that the cluster is working on
this.element = effect.element;
}
};
Spry.Effect.Cluster.prototype.prepareStart = function()
{
this.toggleCluster();
};
//////////////////////////////////////////////////////////////////////
//
// Combination effects
// Custom effects can be build by combining basic effect bahaviour
// like Move, Size, Color, Opacity
//
//////////////////////////////////////////////////////////////////////
Spry.Effect.Fade = function (element, options)
{
if (!this.notStaticAnimator)
return Spry.Effect.Utils.showInitError('Fade');
Spry.Effect.Cluster.call(this, options);
this.name = 'Fade';
var element = Spry.Effect.getElement(element);
this.element = element;
if (!this.element)
return;
var durationInMilliseconds = 1000;
var fromOpacity = 0.0;
var toOpacity = 100.0;
var doToggle = false;
var transition = Spry.fifthTransition;
var fps = 60;
var originalOpacity = 0;
if(/MSIE/.test(navigator.userAgent))
originalOpacity = parseInt(Spry.Effect.getStylePropRegardlessOfDisplayState(this.element, 'filter').replace(/alpha\(opacity=([0-9]{1,3})\)/g, '$1'), 10);
else
originalOpacity = parseInt(Spry.Effect.getStylePropRegardlessOfDisplayState(this.element, 'opacity') * 100, 10);
if (isNaN(originalOpacity))
originalOpacity = 100;
if (options)
{
if (options.duration != null) durationInMilliseconds = options.duration;
if (options.from != null){
if (Spry.Effect.Utils.isPercentValue(options.from))
fromOpacity = Spry.Effect.Utils.getPercentValue(options.from) * originalOpacity / 100;
else
fromOpacity = options.from;
}
if (options.to != null)
{
if (Spry.Effect.Utils.isPercentValue(options.to))
toOpacity = Spry.Effect.Utils.getPercentValue(options.to) * originalOpacity / 100;
else
toOpacity = options.to;
}
if (options.toggle != null) doToggle = options.toggle;
if (options.transition != null) transition = options.transition;
if (options.fps != null) fps = options.fps;
else this.options.transition = transition;
}
fromOpacity = fromOpacity/ 100.0;
toOpacity = toOpacity / 100.0;
options = {duration: durationInMilliseconds, toggle: doToggle, transition: transition, from: fromOpacity, to: toOpacity, fps: fps};
var fadeEffect = new Spry.Effect.Opacity(element, fromOpacity, toOpacity, options);
this.addNextEffect(fadeEffect);
};
Spry.Effect.Fade.prototype = new Spry.Effect.Cluster();
Spry.Effect.Fade.prototype.constructor = Spry.Effect.Fade;
Spry.Effect.Blind = function (element, options)
{
if (!this.notStaticAnimator)
return Spry.Effect.Utils.showInitError('Blind');
Spry.Effect.Cluster.call(this, options);
this.name = 'Blind';
var element = Spry.Effect.getElement(element);
this.element = element;
if (!this.element)
return;
var durationInMilliseconds = 1000;
var doToggle = false;
var kindOfTransition = Spry.circleTransition;
var fps = 60;
var doScaleContent = false;
Spry.Effect.makeClipping(element);
var originalRect = Spry.Effect.getDimensionsRegardlessOfDisplayState(element);
var fromHeightPx = originalRect.height;
var toHeightPx = 0;
var optionFrom = options ? options.from : originalRect.height;
var optionTo = options ? options.to : 0;
www/edgeexpress/jscript/SpryAssets/SpryEffects.js view on Meta::CPAN
}
var pos = (steps % 2 == 0) ? rightPos: leftPos;
options = {duration:Math.ceil(durationInMilliseconds / 2), toggle:false, fps: fps, transition: kindOfTransition};
var effect = new Spry.Effect.Move(element, pos, centerPos, options);
this.addNextEffect(effect);
};
Spry.Effect.Shake.prototype = new Spry.Effect.Cluster();
Spry.Effect.Shake.prototype.constructor = Spry.Effect.Shake;
Spry.Effect.Shake.prototype.doToggle = function(){};
Spry.Effect.Squish = function (element, options)
{
if (!this.notStaticAnimator)
return Spry.Effect.Utils.showInitError('Squish');
if (!options)
options = {};
if (!options.to)
options.to = '0%';
if (!options.from)
options.from = '100%';
options.growCenter = false;
Spry.Effect.Grow.call(this, element, options);
this.name = 'Squish';
}
Spry.Effect.Squish.prototype = new Spry.Effect.Grow();
Spry.Effect.Squish.prototype.constructor = Spry.Effect.Squish;
Spry.Effect.Pulsate = function (element, options)
{
if (!this.notStaticAnimator)
return Spry.Effect.Utils.showInitError('Pulsate');
Spry.Effect.Cluster.call(this, options);
// toggle is not supported
this.options.direction = false;
if (this.options.toggle)
this.options.toggle = false;
var element = Spry.Effect.getElement(element);
var originalOpacity = 0;
this.element = element;
if (!this.element)
return;
this.name = 'Pulsate';
var durationInMilliseconds = 100;
var fromOpacity = 100.0;
var toOpacity = 0.0;
var doToggle = false;
var kindOfTransition = Spry.linearTransition;
var fps = 60;
if(/MSIE/.test(navigator.userAgent))
originalOpacity = parseInt(Spry.Effect.getStylePropRegardlessOfDisplayState(this.element, 'filter').replace(/alpha\(opacity=([0-9]{1,3})\)/g, '$1'), 10);
else
originalOpacity = parseInt(Spry.Effect.getStylePropRegardlessOfDisplayState(this.element, 'opacity') * 100, 10);
if (isNaN(originalOpacity)){
originalOpacity = 100;
}
if (options)
{
if (options.from != null){
if (Spry.Effect.Utils.isPercentValue(options.from))
fromOpacity = Spry.Effect.Utils.getPercentValue(options.from) * originalOpacity / 100;
else
fromOpacity = options.from;
}
if (options.to != null)
{
if (Spry.Effect.Utils.isPercentValue(options.to))
toOpacity = Spry.Effect.Utils.getPercentValue(options.to) * originalOpacity / 100;
else
toOpacity = options.to;
}
if (options.transition != null) kindOfTransition = options.transition;
if (options.fps != null) fps = options.fps;
}
options = {duration:durationInMilliseconds, toggle:doToggle, transition:kindOfTransition, fps:fps};
fromOpacity = fromOpacity / 100.0;
toOpacity = toOpacity / 100.0;
var fadeEffect = new Spry.Effect.Opacity(element, fromOpacity, toOpacity, options);
var appearEffect = new Spry.Effect.Opacity(element, toOpacity, fromOpacity, options);
var steps = parseInt(this.options.duration / 200, 10);
for (var i=0; i < steps; i++){
this.addNextEffect(fadeEffect);
this.addNextEffect(appearEffect);
}
};
Spry.Effect.Pulsate.prototype = new Spry.Effect.Cluster();
Spry.Effect.Pulsate.prototype.constructor = Spry.Effect.Pulsate;
Spry.Effect.Pulsate.prototype.doToggle = function(){};
Spry.Effect.Puff = function (element, options)
{
if (!this.notStaticAnimator)
return Spry.Effect.Utils.showInitError('Puff');
Spry.Effect.Cluster.call(this, options);
var element = Spry.Effect.getElement(element);
this.element = element;
if (!this.element)
return;
this.name = 'Puff';
var doToggle = false;
var doScaleContent = false;
var durationInMilliseconds = 1000;
var kindOfTransition = Spry.fifthTransition;
var fps = 60;
Spry.Effect.makePositioned(element); // for move
if (options){
if (options.toggle != null) doToggle = options.toggle;
( run in 0.583 second using v1.01-cache-2.11-cpan-39bf76dae61 )