Nav Bar height is 43 pts? - iphone

According to every online resource, the Nav Bar height should be 44pts (88px on Retina screens).
Indeed, when I take a screenshot of my iPhone (see below), the Status bar's height is 20pts, and the NavBar's height is 44pts, but that's split into a 1pt white pixels, and 43 "blue" pixels:
When I develop my app and create a NavBar (standard), there is no "white" pixel between the StatusBar and the NavBar, so the NavBar's height is 43pts (and not 44pts). This makes the inner window 1pt higher:
My entire code is simply 5 lines (app.js):
var mainWindow = Titanium.UI.createWindow();
var innerWindow = Titanium.UI.createWindow({ title : "Settings" });
var navGroup = Titanium.UI.iPhone.createNavigationGroup({ window : innerWindow });
mainWindow.add(navGroup);
mainWindow.open();
Any ideas??

Maybe it'll help some one some day, if you add "top : 0" when creating the NavigationGroup, you'll get that extra pixel line :)
var navGroup = Titanium.UI.iPhone.createNavigationGroup({ top : 0, window : innerWindow });

Since iOS 6 you've got a 1 point shadow line under the navigation bar.
This may be the cause of you problem.

Related

Increase element opacity but accounting for the size of the element and position of it's bottom relative to "scrollTop"

I found a great example for this approach and it works fairly well but it starts changing the opacity when the TOP of the element scrolls off the page. Unfortunately with a larger element the visibility (opacity decrease) starts way too soon. I'm trying to figure out how to start lowering the opacity when the bottom of the element is in near proximity to the top of the top of the screen so that all elements start fading at the same time in relationship to their bottom (not their top).
Any ideas on how to accommodate that with this code? I like this code in terms of being able to control speed of the opacity change as well. Maybe leveraging element height?
Thanks!!
<script type="text/javascript">
$(function() {
var documentEl = $(document),
fadeElem = $('.fade-scroll');
documentEl.on('scroll', function() {
var currScrollPos = documentEl.scrollTop();
fadeElem.each(function() {
var $this = $(this),
elemOffsetTop = $this.offset().top;
if (currScrollPos > elemOffsetTop) $this.css('opacity', 1 - (currScrollPos-elemOffsetTop)/200); /* this number effects speed of fade aka opacity reduction*/
});
});
});
</script>

How I make sticky nav bar which has responsive element without specific height above it?

So I have 100% of screen width header image at the top of the page and text element below the image. Below the text element I tried to make sticky navigation bar with this code:
$(function(){
var stickyRibbonTop = $('#stickyribbon').offset().top;
$(window).scroll(function(){
if( $(window).scrollTop() > stickyRibbonTop ) {
$('#stickyribbon').css({position: 'fixed', top: '0px'});
} else {
$('#stickyribbon').css({position: 'static', top: '0px'});
}
});
});
Problem is that sticky nav bar jumps to the top of the page already when I scroll down the height of the text element. So it totally ignores the header image. I have height auto for this image but it obviously does nothing.
Solved it by myself. Solution was to make div with no height and padding-bottom as percentage of header image's height to its width and put the image in that div.

Change padding on fancybox depending on image width

I am new to javascript and jQuery and am trying to make a slideshow using Fancybox.
The problem is that I want the images to display on a box of the same size regardless of whether they are portrait or landscape images. My images are all either 700 X 525 for landscape or 525 X 700 for portrait.
The way I have it the landscape images load like it is showed on the top of the image below, the portrait images load as shown in the middle, and I want the portrait images to load as shown on the bottom, with the box with the same dimensions as if it were landscape:
I think what I should do is change the left padding depending on the image dimensions but I have no idea how.
Thank you for your help in advance.
I am using Fancybox version: 2.1.4 and I have set the defaults as such:
padding : 15,
margin : 20,
width : 800,
height : 600,
minWidth : 100,
minHeight : 100,
maxWidth : 9999,
maxHeight : 9999,
autoSize : true,
autoHeight : false,
autoWidth : false,
autoResize : true,
autoCenter : !isTouch,
fitToView : true,
aspectRatio : false,
topRatio : 0.5,
leftRatio : 0.5,
I know this post is 11 months old, but I thought I would share my solution in case it helps someone else out in the future.
Basically I have set a min-width css attribute onto the fancybox element and am comparing that against the current image width, if it is smaller I am adding padding to the fancybox element so that the fancybox element stays the same width but the image inside is horizontally centered.
Step 1: in your css set a min-width on the fancybox element. This is the width that you want your fancybox element to stay at regardless of image width.
.fancybox-wrap { min-width: 1120px; }
Step 2: add in the afterLoad function when you call fancybox
$(".fancybox").fancybox({
afterLoad: function(current) {
var $el = $(".fancybox-wrap").eq(0); // grab the main fancybox element
var getcurrwidth = current.width; // grab the currrent width of the element
var getdesiredwidth = $el.css('min-width'); // grab our min-width that we set from the css
var currwidth = Number(getcurrwidth);
var desiredwidth = Number(getdesiredwidth.replace('px', ''));
if (currwidth < desiredwidth)
{
var custompadding = (desiredwidth - currwidth) * 0.5; // if the width of the element is smaller than our desired width then set padding amount
this.skin.css({'padding-left': custompadding+'px', 'padding-right': custompadding+'px' }); // add equal padding to the fancybox skin element
}
}
});

Make Firefox Panel fit content

I'm manually porting an extension I wrote in Chrome over to Firefox. I'm attaching a panel to a widget, and setting the content of that panel as an HTML file. How can I make the panel shrink and grow with the content? There's a lot of unsightly scroll bars and grey background right now.
var data = require("self").data;
var text_entry = require("panel").Panel({
width: 320,
height: 181,
contentURL: data.url("text-entry.html"),
contentScriptFile: data.url("get-text.js")
});
require("widget").Widget({
label: "Text entry",
id: "text-entry",
contentURL: "http://www.mozilla.org/favicon.ico",
panel: text_entry
});
Not setting the height property of the panel makes it quite tall.
You might want to check out this example that resizes the panel based on the document loaded. If you want to resize based on changes to the content size, at least on initial load:
https://builder.addons.mozilla.org/package/150225/latest/
( sorry for the delay in respinding, been afk travelling )

Fancybox2: horizontal transitions instead of vertical - how?

In the examples page when you search (CTRL+F) for image gallery and click the first image, there's this image gallery which you can browse with next/prev arrows. The animation between them is vertical -- the images fly vertically. How does one set them to fly horizontally?
In the help I found:
openMethod / closeMethod / nextMethod / prevMethod
Method from $.fancybox.transitions() that handles transition (you can
add custom effects there)
But I don't know where to go from here.
Also, this seems to be slightly related.
You can create your own custom transitions from here:
http://jsfiddle.net/xZBBS/
$(".fancybox-thumb").fancybox({
prevEffect : 'none',
nextEffect : 'none',
helpers : {
title : {
type: 'outside'
},
thumbs : {
width : 50,
height : 50
}
}
});
try this i am sure this will help