summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthewsotoudeh <matthewsot@outlook.com>2014-05-03 20:05:42 -0700
committermatthewsotoudeh <matthewsot@outlook.com>2014-05-03 20:05:42 -0700
commitc361896c162e32dd37180f7f0d9e302aa4998999 (patch)
tree368b99aa5296a043b24a5cdb5676174de589e774
parent9489b3df5a82fa37914ba1afe4e2752d168fd4dc (diff)
Added new animations & updated readme
-rw-r--r--Animations.js50
-rw-r--r--Animations.js.map1
-rw-r--r--Animations.ts44
-rw-r--r--README.md37
-rw-r--r--Wedge.js45
-rw-r--r--Wedge.js.map2
-rw-r--r--Wedge.ts29
7 files changed, 169 insertions, 39 deletions
diff --git a/Animations.js b/Animations.js
new file mode 100644
index 0000000..30f1851
--- /dev/null
+++ b/Animations.js
@@ -0,0 +1,50 @@
+/// <reference path="jquery.d.ts" />
+//Animations that require other libraries to work
+//Requires jquery.GSAP: http://www.greensock.com/jquery-gsap-plugin/
+var ScaleAnimation = (function () {
+ function ScaleAnimation() {
+ }
+ ScaleAnimation.prototype.animateIn = function (overlayId, contentId) {
+ $('#' + overlayId).fadeIn('slow');
+ var content = '#' + contentId;
+ $(content).css('transform', 'matrix(0.2, 0, 0, 0.2, 0, 0)');
+ $(content).animate({
+ scaleX: 1,
+ scaleY: 1,
+ "opacity": 1
+ });
+ };
+ ScaleAnimation.prototype.animateOut = function (overlayId, contentId, completed) {
+ $('#' + overlayId).fadeOut('slow', completed);
+ $('#' + contentId).animate({
+ scaleX: 0.2,
+ scaleY: 0.2,
+ "opacity": 0
+ });
+ };
+ return ScaleAnimation;
+})();
+
+//Requires jQuery.GSAP for scale animations
+var RotationAnimation = (function () {
+ function RotationAnimation() {
+ }
+ RotationAnimation.prototype.animateIn = function (overlayId, contentId) {
+ $('#' + overlayId).fadeIn('slow');
+ var content = '#' + contentId;
+ $(content).css('transform', 'matrix3d(0.93969, 0.34202, 0, 0, -0.34202, 0.93969, 0, 0, 0, 0, 1, -0.05, 0, 0, 0, 1)');
+ $(content).animate({
+ rotationZ: 0,
+ "opacity": 1
+ });
+ };
+ RotationAnimation.prototype.animateOut = function (overlayId, contentId, completed) {
+ $('#' + overlayId).fadeOut('slow', completed);
+ $('#' + contentId).animate({
+ rotationZ: -20,
+ "opacity": 0
+ });
+ };
+ return RotationAnimation;
+})();
+//# sourceMappingURL=Animations.js.map
diff --git a/Animations.js.map b/Animations.js.map
new file mode 100644
index 0000000..dff9750
--- /dev/null
+++ b/Animations.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"Animations.js","sourceRoot":"","sources":["Animations.ts"],"names":["ScaleAnimation","ScaleAnimation.constructor","ScaleAnimation.animateIn","ScaleAnimation.animateOut","RotationAnimation","RotationAnimation.constructor","RotationAnimation.animateIn","RotationAnimation.animateOut"],"mappings":"AAAA,oCAAoC;AACpC,iDAAiD;AAEjD,oEAAoE;AACpE;IAAAA;IAmBAC,CAACA;AAAAD,IAlBGA,qCAAAA,UAAUA,SAASA,EAAEA,SAASA;QAC1BE,CAACA,CAACA,GAAGA,GAAGA,SAASA,CAACA,CAACA,MAAMA,CAACA,MAAMA,CAACA;QACjCA,IAAIA,OAAOA,GAAGA,GAAGA,GAAGA,SAASA;QAC7BA,CAACA,CAACA,OAAOA,CAACA,CAACA,GAAGA,CAACA,WAAWA,EAAEA,8BAA8BA,CAACA;QAC3DA,CAACA,CAACA,OAAOA,CAACA,CAACA,OAAOA,CAACA;YACfA,MAAMA,EAAEA,CAACA;YACTA,MAAMA,EAAEA,CAACA;YACTA,SAASA,EAAEA,CAACA;SACfA,CAACA;IACNA,CAACA;IACDF,sCAAAA,UAAWA,SAASA,EAAEA,SAASA,EAAEA,SAASA;QACtCG,CAACA,CAACA,GAAGA,GAAGA,SAASA,CAACA,CAACA,OAAOA,CAACA,MAAMA,EAAEA,SAASA,CAACA;QAC7CA,CAACA,CAACA,GAAGA,GAAGA,SAASA,CAACA,CAACA,OAAOA,CAACA;YACvBA,MAAMA,EAAEA,GAAGA;YACXA,MAAMA,EAAEA,GAAGA;YACXA,SAASA,EAAEA,CAACA;SACfA,CAACA;IACNA,CAACA;IACLH,sBAACA;AAADA,CAACA,IAAA;;AAED,2CAA2C;AAC3C;IAAAI;IAiBAC,CAACA;AAAAD,IAhBGA,wCAAAA,UAAUA,SAASA,EAAEA,SAASA;QAC1BE,CAACA,CAACA,GAAGA,GAAGA,SAASA,CAACA,CAACA,MAAMA,CAACA,MAAMA,CAACA;QACjCA,IAAIA,OAAOA,GAAGA,GAAGA,GAAGA,SAASA;QAC7BA,CAACA,CAACA,OAAOA,CAACA,CAACA,GAAGA,CAACA,WAAWA,EAAEA,uFAAuFA,CAACA;QACpHA,CAACA,CAACA,OAAOA,CAACA,CAACA,OAAOA,CAACA;YACfA,SAASA,EAAEA,CAACA;YACZA,SAASA,EAAEA,CAACA;SACfA,CAACA;IACNA,CAACA;IACDF,yCAAAA,UAAWA,SAASA,EAAEA,SAASA,EAAEA,SAASA;QACtCG,CAACA,CAACA,GAAGA,GAAGA,SAASA,CAACA,CAACA,OAAOA,CAACA,MAAMA,EAAEA,SAASA,CAACA;QAC7CA,CAACA,CAACA,GAAGA,GAAGA,SAASA,CAACA,CAACA,OAAOA,CAACA;YACvBA,SAASA,EAAEA,CAACA,EAAEA;YACdA,SAASA,EAAEA,CAACA;SACfA,CAACA;IACNA,CAACA;IACLH,yBAACA;AAADA,CAACA,IAAA"} \ No newline at end of file
diff --git a/Animations.ts b/Animations.ts
new file mode 100644
index 0000000..29e3642
--- /dev/null
+++ b/Animations.ts
@@ -0,0 +1,44 @@
+/// <reference path="jquery.d.ts" />
+//Animations that require other libraries to work
+
+//Requires jquery.GSAP: http://www.greensock.com/jquery-gsap-plugin/
+class ScaleAnimation implements IWedgeAnimator {
+ animateIn(overlayId, contentId) {
+ $('#' + overlayId).fadeIn('slow');
+ var content = '#' + contentId;
+ $(content).css('transform', 'matrix(0.2, 0, 0, 0.2, 0, 0)');
+ $(content).animate({
+ scaleX: 1,
+ scaleY: 1,
+ "opacity": 1
+ });
+ }
+ animateOut(overlayId, contentId, completed) {
+ $('#' + overlayId).fadeOut('slow', completed);
+ $('#' + contentId).animate({
+ scaleX: 0.2,
+ scaleY: 0.2,
+ "opacity": 0
+ });
+ }
+}
+
+//Requires jQuery.GSAP for scale animations
+class RotationAnimation implements IWedgeAnimator {
+ animateIn(overlayId, contentId) {
+ $('#' + overlayId).fadeIn('slow');
+ var content = '#' + contentId;
+ $(content).css('transform', 'matrix3d(0.93969, 0.34202, 0, 0, -0.34202, 0.93969, 0, 0, 0, 0, 1, -0.05, 0, 0, 0, 1)');
+ $(content).animate({
+ rotationZ: 0,
+ "opacity": 1
+ });
+ }
+ animateOut(overlayId, contentId, completed) {
+ $('#' + overlayId).fadeOut('slow', completed);
+ $('#' + contentId).animate({
+ rotationZ: -20,
+ "opacity": 0
+ });
+ }
+} \ No newline at end of file
diff --git a/README.md b/README.md
index 6ce3b89..fec12eb 100644
--- a/README.md
+++ b/README.md
@@ -2,3 +2,40 @@ wedge
=====
A drop-dead simple lightbox written in Typescript
+
+Wedge can display images, YouTube videos, and divs easily.
+
+To show an image with the title text "Hey there!", just use:
+```
+initWedge('img.jpg', 'img', 'Hey there!');
+```
+
+Like animations? Wedge makes them easy -
+```
+initWedge('https://www.youtube.com/watch?v=wZZ7oFKsKzY', 'youtube', '', new SlideInAnimation());
+```
+
+Wedge comes with two built-in animations (FadeAnimation and SlideAnimation), but you can easily create your own:
+```
+//(Typescript)
+class FadeAnimation implements IWedgeAnimator {
+ animateIn(overlayId, contentId): void {
+ $('#' + overlayId).fadeIn('slow');
+ $('#' + contentId).fadeIn('slow');
+ }
+
+ animateOut(overlayId, contentId, completed): void {
+ $('#' + overlayId).fadeOut('slow');
+ $('#' + contentId).fadeOut('slow');
+ }
+}
+
+initWedge('some-div-id', 'div', '', new FadeAnimation());
+```
+
+There are even more complicated animations (like ScaleAnimation and RotateAnimation) which use separate animation libraries. You can find and use those in Animations.ts:
+
+And if you don't like a default, you can customize just about any part of the lightbox through parameters:
+```
+initWedge(link: 'some-div-id', type: 'div', title: 'title', animator: new ScaleAnimation(), exitOnEscape: true, doAutoPosition: true, opacity: 0.8, allowExit: true, overlayId: 'overlay-id', contentId: 'content-container-id');
+``` \ No newline at end of file
diff --git a/Wedge.js b/Wedge.js
index 29b1b4f..bb17f02 100644
--- a/Wedge.js
+++ b/Wedge.js
@@ -1,43 +1,42 @@
/// <reference path="jquery.d.ts" />
-var SimpleFadeAnimation = (function () {
- function SimpleFadeAnimation() {
+var FadeAnimation = (function () {
+ function FadeAnimation() {
}
- SimpleFadeAnimation.prototype.animateIn = function (overlayId, contentId) {
+ FadeAnimation.prototype.animateIn = function (overlayId, contentId) {
$('#' + overlayId).fadeIn('slow');
$('#' + contentId).fadeIn('slow');
};
- SimpleFadeAnimation.prototype.animateOut = function (overlayId, contentId, completed) {
+ FadeAnimation.prototype.animateOut = function (overlayId, contentId, completed) {
$('#' + overlayId).fadeOut('slow');
- $('#' + contentId).fadeOut('show');
+ $('#' + contentId).fadeOut('slow');
};
- return SimpleFadeAnimation;
+ return FadeAnimation;
})();
-//Requires jQuery.GSAP for scale animations
-var ScaleInAnimation = (function () {
- function ScaleInAnimation() {
+var SlideAnimation = (function () {
+ function SlideAnimation() {
}
- ScaleInAnimation.prototype.animateIn = function (overlayId, contentId) {
+ SlideAnimation.prototype.animateIn = function (overlayId, contentId) {
$('#' + overlayId).fadeIn('slow');
var content = '#' + contentId;
- $(content).css('transform', 'matrix(0.2, 0, 0, 0.2, 0, 0)');
+ var regularMarginLeft = parseInt($(content).css('margin-left').replace('px', ''));
+ $(content).css('margin-left', (regularMarginLeft - 50) + 'px');
$(content).animate({
- scaleX: 1,
- scaleY: 1,
- "opacity": 1
+ "opacity": 1,
+ marginLeft: regularMarginLeft + 'px'
});
};
- ScaleInAnimation.prototype.animateOut = function (overlayId, contentId, completed) {
+ SlideAnimation.prototype.animateOut = function (overlayId, contentId, completed) {
$('#' + overlayId).fadeOut('slow', completed);
+ var regularMarginLeft = parseInt($('#' + contentId).css('margin-left').replace('px', ''));
$('#' + contentId).animate({
- scaleX: 0.2,
- scaleY: 0.2,
- "opacity": 0
+ "opacity": 0,
+ marginLeft: (regularMarginLeft - 50) + 'px'
});
};
- return ScaleInAnimation;
+ return SlideAnimation;
})();
/* initWedge()
@@ -45,15 +44,15 @@ var ScaleInAnimation = (function () {
*
* link: A link to the youtube video or picture
* title: Text displayed below the content
-* type: The type of link provided - youtube, pic, or div
+* type: The type of link provided - youtube, img, or div
* animator: An IWedgeAnimator that controls how animations are handled
* exitOnEscape: Controls whether the lightbox can be exited by pressing the escape key
* doAutoPosition: Controls whether the lightbox is automatically centered
* opacity: The final opacity of the overlay
* allowExit: Controls whether the user is allowed to exit the lightbox
*/
-function initWedge(link, title, type, animator, exitOnEscape, doAutoPosition, opacity, allowExit, overlayId, contentId) {
- if (typeof animator === "undefined") { animator = new SimpleFadeAnimation; }
+function initWedge(link, type, title, animator, exitOnEscape, doAutoPosition, opacity, allowExit, overlayId, contentId) {
+ if (typeof animator === "undefined") { animator = new FadeAnimation; }
if (typeof exitOnEscape === "undefined") { exitOnEscape = true; }
if (typeof doAutoPosition === "undefined") { doAutoPosition = true; }
if (typeof opacity === "undefined") { opacity = 0.9; }
@@ -105,7 +104,7 @@ function initWedge(link, title, type, animator, exitOnEscape, doAutoPosition, op
case 'youtube':
$(content).append('<iframe id="youtubeFrame" width="853" height="480" src="' + link.replace('/watch?v=', '/embed/').replace(/&.*/, '') + '" frameborder="0" allowfullscreen></iframe><h3 style="color:#A0A0A0;">' + title + '</h3>');
break;
- case 'pic':
+ case 'img':
$(content).append('<img src="' + link + '" style="max-height:' + (window.innerHeight - 100) + 'px;max-width:' + (window.innerWidth - 100) + 'px;"/><h3 style="color:#A0A0A0;">' + title + '</h3>');
break;
case 'div':
diff --git a/Wedge.js.map b/Wedge.js.map
index dcc31a1..4ce2f7b 100644
--- a/Wedge.js.map
+++ b/Wedge.js.map
@@ -1 +1 @@
-{"version":3,"file":"Wedge.js","sourceRoot":"","sources":["Wedge.ts"],"names":["SimpleFadeAnimation","SimpleFadeAnimation.constructor","SimpleFadeAnimation.animateIn","SimpleFadeAnimation.animateOut","ScaleInAnimation","ScaleInAnimation.constructor","ScaleInAnimation.animateIn","ScaleInAnimation.animateOut","initWedge"],"mappings":"AAAA,oCAAoC;;AAOpC;IAAAA;IAUAC,CAACA;AAAAD,IATGA,0CAAAA,UAAUA,SAASA,EAAEA,SAASA;QAC1BE,CAACA,CAACA,GAAGA,GAAGA,SAASA,CAACA,CAACA,MAAMA,CAACA,MAAMA,CAACA;QACjCA,CAACA,CAACA,GAAGA,GAAGA,SAASA,CAACA,CAACA,MAAMA,CAACA,MAAMA,CAACA;IACrCA,CAACA;;IAEDF,2CAAAA,UAAWA,SAASA,EAAEA,SAASA,EAAEA,SAASA;QACtCG,CAACA,CAACA,GAAGA,GAAGA,SAASA,CAACA,CAACA,OAAOA,CAACA,MAAMA,CAACA;QAClCA,CAACA,CAACA,GAAGA,GAAGA,SAASA,CAACA,CAACA,OAAOA,CAACA,MAAMA,CAACA;IACtCA,CAACA;IACLH,2BAACA;AAADA,CAACA,IAAA;;AAED,2CAA2C;AAC3C;IAAAI;IAmBAC,CAACA;AAAAD,IAlBGA,uCAAAA,UAAUA,SAASA,EAAEA,SAASA;QAC1BE,CAACA,CAACA,GAAGA,GAAGA,SAASA,CAACA,CAACA,MAAMA,CAACA,MAAMA,CAACA;QACjCA,IAAIA,OAAOA,GAAGA,GAAGA,GAAGA,SAASA;QAC7BA,CAACA,CAACA,OAAOA,CAACA,CAACA,GAAGA,CAACA,WAAWA,EAAEA,8BAA8BA,CAACA;QAC3DA,CAACA,CAACA,OAAOA,CAACA,CAACA,OAAOA,CAACA;YACfA,MAAMA,EAAEA,CAACA;YACTA,MAAMA,EAAEA,CAACA;YACTA,SAASA,EAAEA,CAACA;SACfA,CAACA;IACNA,CAACA;IACDF,wCAAAA,UAAWA,SAASA,EAAEA,SAASA,EAAEA,SAASA;QACtCG,CAACA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1CA,IAAIA,SAASA,CAAEA;QACXA,IAAIA,MAAMA,GAAGA;YACTA,QAAQA,CAACA,UAAUA,CAACA,SAASA,EAAEA,SAASA,EAAEA;gBACtCA,IAAIA,IAAIA,IAAIA,KAAKA,CAAEA;oBACfA,CAACA,CAACA,GAAGA,GAAGA,IAAIA,CAACA,CAACA,QAAQA,CAACA,CAACA,CAACA,MAAMA,CAACA,CAACA;oBACjCA,CAACA,CAACA,GAAGA,GAAGA,IAAIA,CAACA,CAACA,IAAIA,CAACA,CAACA;iBACvBA;gBACDA,CAACA,CAACA,OAAOA,CAACA,CAACA,MAAMA,CAACA,OAAOA,EAAEA,MAAMA,CAACA;gBAClCA,CAACA,CAACA,QAAQA,CAACA,CAACA,MAAMA,CAACA,OAAOA,EAAEA,KAAKA,CAACA;;gBAElCA,CAACA,CAACA,OAAOA,CAACA,CAACA,IAAIA,CAACA,CAACA,CAACA,MAAMA,CAACA,CAACA;gBAC1BA,CAACA,CAACA,OAAOA,CAACA,CAACA,IAAIA,CAACA,CAACA,CAACA,MAAMA,CAACA,CAACA;YAC9BA,CAACA,CAACA;QACNA,CAACA;;QAEDA,IAAIA,KAAKA,GAAGA,UAACA,CAACA;YACVA,IAAIA,CAACA,CAACA,OAAOA,IAAIA,EAAEA,CAAEA;gBACjBA,MAAMA,CAACA,CAACA;aACXA;QACLA,CAACA;;QAEDA,CAACA,CAACA,OAAOA,CAACA,CAACA,KAAKA,CAACA,MAAMA,CAACA;QACxBA,IAAIA,YAAYA,CAAEA;YACdA,CAACA,CAACA,QAAQA,CAACA,CAACA,KAAKA,CAACA,KAAKA,CAACA;SAC3BA;KACJA;;IACDA;;MAEGA;IACHA,CAACA,CAACA,MAAMA,CAACA,CAACA,MAAMA,CAACA,WAAWA,GAAGA,SAASA,GAAGA,2EAA2EA,CAACA;IACvHA,QAAQA,IAAIA,CAACA;QACTA,KAAKA,SAASA;YACVA,CAACA,CAACA,OAAOA,CAACA,CAACA,MAAMA,CAACA,0DAA0DA,G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AAEA,cAAcA,CAACA;IAC7CA,QAAQA,CAACA,SAASA,CAACA,SAASA,EAAEA,SAASA,CAACA;AAC5CA,CAACA"} \ No newline at end of file
+{"version":3,"file":"Wedge.js","sourceRoot":"","sources":["Wedge.ts"],"names":["FadeAnimation","FadeAnimation.constructor","FadeAnimation.animateIn","FadeAnimation.animateOut","SlideAnimation","SlideAnimation.constructor","SlideAnimation.animateIn","SlideAnimation.animateOut","initWedge"],"mappings":"AAAA,oCAAoC;;AAOpC;IAAAA;IAUAC,CAACA;AAAAD,IATGA,oCAAAA,UAAUA,SAASA,EAAEA,SAASA;QAC1BE,CAACA,CAACA,GAAGA,GAAGA,SAASA,CAACA,CAACA,MAAMA,CAACA,MAAMA,CAACA;QACjCA,CAACA,CAACA,GAAGA,GAAGA,SAASA,CAACA,CAACA,MAAMA,CAACA,MAAMA,CAACA;IACrCA,CAACA;;IAEDF,qCAAAA,UAAWA,SAASA,EAAEA,SAASA,EAAEA,SAASA;QACtCG,CAACA,CAACA,GAAGA,GAAGA,SAASA,CAACA,CAACA,OAAOA,CAACA,MAAMA,CAACA;QAClCA,CAACA,CAACA,GAAGA,GAAGA,SAASA,CAACA,CAACA,OAAOA,CAACA,MAAMA,CAACA;IACtCA,CAACA;IACLH,qBAACA;AAADA,CAACA,IAAA;;AAED;IAAAI;IAmBAC,CAACA;AAAAD,IAlBGA,qCAAAA,UAAUA,SAASA,EAAEA,SAASA;QAC1BE,CAACA,CAACA,GAAGA,GAAGA,SAASA,CAACA,CAACA,MAAMA,CAACA,MAAMA,CAACA;QACjCA,IAAIA,OAAOA,GAAGA,GAAGA,GAAGA,SAASA;QAC7BA,IAAIA,iBAAiBA,GAAGA,QAAQA,CAACA,CAACA,CAACA,OAAOA,CAACA,CAACA,GAAGA,CAACA,aAAaA,CAACA,CAACA,OAAOA,CAACA,IAAIA,EAAEA,EAAEA,CAACA,CAACA;QACjFA,CAACA,CAACA,OAAOA,CAACA,CAACA,GAAGA,CAACA,aAAaA,EAAEA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AGA,EAAEA,KAAKA,EAAEA,IAAIA,EAAEA,KAAKA,EAAEA,MAAMA,EAAEA,GAAGA,GAAGA,CAACA,CAACA,CAACA,OAAOA,CAACA,CAACA,MAAMA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,UAAUA,GAAGA,CAACA,CAACA,CAACA,OAAOA,CAACA,CAACA,KAAKA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,IAAIA,EAAEA,CAACA,EAAEA,kEAAkEA;KAC1MA;IACDA,IAAIA,cAAcA,GAAGA,CAACA,CAACA,OAAOA,CAACA,CAACA,GAAGA,CAACA,aAAaA,CAACA;IAClDA,CAACA,CAACA,OAAOA,CAACA,CAACA,GAAGA,CAACA,aAAaA,EAAEA,cAAcA,CAACA;IAC7CA,QAAQA,CAACA,SAASA,CAACA,SAASA,EAAEA,SAASA,CAACA;AAC5CA,CAACA"} \ No newline at end of file
diff --git a/Wedge.ts b/Wedge.ts
index b9990eb..8303e5d 100644
--- a/Wedge.ts
+++ b/Wedge.ts
@@ -5,7 +5,7 @@ interface IWedgeAnimator {
animateOut(overlayId, contentId, completed): void;
}
-class SimpleFadeAnimation implements IWedgeAnimator {
+class FadeAnimation implements IWedgeAnimator {
animateIn(overlayId, contentId): void {
$('#' + overlayId).fadeIn('slow');
$('#' + contentId).fadeIn('slow');
@@ -13,28 +13,27 @@ class SimpleFadeAnimation implements IWedgeAnimator {
animateOut(overlayId, contentId, completed): void {
$('#' + overlayId).fadeOut('slow');
- $('#' + contentId).fadeOut('show');
+ $('#' + contentId).fadeOut('slow');
}
}
-//Requires jQuery.GSAP for scale animations
-class ScaleInAnimation implements IWedgeAnimator {
+class SlideAnimation implements IWedgeAnimator {
animateIn(overlayId, contentId) {
$('#' + overlayId).fadeIn('slow');
var content = '#' + contentId;
- $(content).css('transform', 'matrix(0.2, 0, 0, 0.2, 0, 0)');
+ var regularMarginLeft = parseInt($(content).css('margin-left').replace('px', ''));
+ $(content).css('margin-left', (regularMarginLeft - 50) + 'px');
$(content).animate({
- scaleX: 1,
- scaleY: 1,
- "opacity": 1
- });
+ "opacity": 1,
+ marginLeft: regularMarginLeft + 'px'
+ });
}
animateOut(overlayId, contentId, completed) {
$('#' + overlayId).fadeOut('slow', completed);
+ var regularMarginLeft = parseInt($('#' + contentId).css('margin-left').replace('px', ''));
$('#' + contentId).animate({
- scaleX: 0.2,
- scaleY: 0.2,
- "opacity": 0
+ "opacity": 0,
+ marginLeft: (regularMarginLeft - 50) + 'px'
});
}
}
@@ -44,14 +43,14 @@ class ScaleInAnimation implements IWedgeAnimator {
*
* link: A link to the youtube video or picture
* title: Text displayed below the content
- * type: The type of link provided - youtube, pic, or div
+ * type: The type of link provided - youtube, img, or div
* animator: An IWedgeAnimator that controls how animations are handled
* exitOnEscape: Controls whether the lightbox can be exited by pressing the escape key
* doAutoPosition: Controls whether the lightbox is automatically centered
* opacity: The final opacity of the overlay
* allowExit: Controls whether the user is allowed to exit the lightbox
*/
-function initWedge(link, title, type, animator: IWedgeAnimator = new SimpleFadeAnimation, exitOnEscape = true, doAutoPosition = true, opacity = 0.9, allowExit = true, overlayId = 'wedge-overlay', contentId = 'wedge-content') {
+function initWedge(link, type, title, animator: IWedgeAnimator = new FadeAnimation, exitOnEscape = true, doAutoPosition = true, opacity = 0.9, allowExit = true, overlayId = 'wedge-overlay', contentId = 'wedge-content') {
/*
* Shows the overlay
*/
@@ -96,7 +95,7 @@ function initWedge(link, title, type, animator: IWedgeAnimator = new SimpleFadeA
case 'youtube':
$(content).append('<iframe id="youtubeFrame" width="853" height="480" src="' + link.replace('/watch?v=', '/embed/').replace(/&.*/, '') + '" frameborder="0" allowfullscreen></iframe><h3 style="color:#A0A0A0;">' + title + '</h3>');
break;
- case 'pic':
+ case 'img':
$(content).append('<img src="' + link + '" style="max-height:' + (window.innerHeight - 100) + 'px;max-width:' + (window.innerWidth - 100) + 'px;"/><h3 style="color:#A0A0A0;">' + title + '</h3>');
break;
case 'div':
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback