forked from 0x2620/oxjs
some fixes for map, range and videopreview
This commit is contained in:
parent
8ea49fab73
commit
c6d67420a8
6 changed files with 88 additions and 37 deletions
|
|
@ -25,11 +25,14 @@ Ox.VideoPreview = function(options, self) {
|
|||
self.loaded = [];
|
||||
self.queue = [];
|
||||
|
||||
self.$frame = $('<img>')
|
||||
self.$frameElement = $('<div>')
|
||||
.addClass('OxFrame')
|
||||
.appendTo(that.$element)
|
||||
|
||||
self.$frame = $('<img>')
|
||||
.attr({src: self.options.getFrame(self.options.position)})
|
||||
.css(getFrameCSS())
|
||||
.appendTo(that.$element);
|
||||
.appendTo(self.$frameElement);
|
||||
|
||||
self.$timeline = $('<img>')
|
||||
.addClass('OxTimeline')
|
||||
|
|
@ -65,19 +68,25 @@ Ox.VideoPreview = function(options, self) {
|
|||
}
|
||||
|
||||
function getFrameCSS() {
|
||||
var css = {};
|
||||
// fixme: these are still wrong
|
||||
if (!self.options.scaleToFill) {
|
||||
css.width = self.options.width;
|
||||
css.height = Math.round(css.width / self.options.frameRatio);
|
||||
css.marginTop = Math.floor((self.options.height - 16 - css.height) / 2);
|
||||
var css = {},
|
||||
elementWidth = self.options.width,
|
||||
elementHeight = self.options.height - 16,
|
||||
elementRatio = elementWidth / elementHeight,
|
||||
frameRatio = self.options.frameRatio,
|
||||
frameIsWider = frameRatio > elementRatio;
|
||||
if (self.options.scaleToFill) {
|
||||
css.width = frameIsWider ? elementHeight * frameRatio : elementWidth;
|
||||
css.height = frameIsWider ? elementHeight : elementWidth / frameRatio;
|
||||
css.marginLeft = frameIsWider ? (elementWidth - css.width) / 2 : 0;
|
||||
css.marginTop = frameIsWider ? 0 : (elementHeight - css.height) / 2;
|
||||
} else {
|
||||
css.height = self.options.height - 16;
|
||||
css.width = Math.round(css.height * self.options.frameRatio);
|
||||
css.marginLeft = Math.floor((self.options.width - css.width) / 2);
|
||||
css.width = frameIsWider ? elementWidth : elementHeight * frameRatio;
|
||||
css.height = frameIsWider ? elementWidth / frameRatio : elementHeight;
|
||||
css.marginLeft = frameIsWider ? 0 : (css.width - elementWidth) / 2;
|
||||
css.marginTop = frameIsWider ? (css.height - elementHeight) / 2 : 0;
|
||||
}
|
||||
return Ox.map(css, function(value) {
|
||||
return value + 'px';
|
||||
return Math.round(value) + 'px';
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue