I'd really like to be able to decrease the amount of padding at the top of all my level 2 reveal.js slides (version 2.6.2). It doesn't appear to be possible to customise this with CSS because the offset is a negative number calculated dynamically.
e.g. in http://fommil.github.io/scalax14/#/5/1 I would like to reclaim at least 200 pixels at the top. The top parameter is currently being calculated to be -350px but I'd really rather it was closer to -500px.
Is there a way to do this with config?
Reveal keeps the aspect ratio of the resolution you entered in the config.
If you want your slides to have less padding, there are multiple ways:
disable centering:
center: true, // add this in init or config
slides get positioned at the top of the page, and all the padding happens at the bottom
use a 4:3 format for your slides
width: 1024, // add this in init or config
height: 768,
this will move all padding to sides of the page (well, assuming the browser window is not resized) as long as the page ratio is wider than 4:3
create fully responsive slides:
var resizeSlide = function() {
Reveal.configure({
width: window.innerWidth,
height: window.innerHeight
});
}
setInterval(resizeSlide, 1000);
you will then need to make your slides responsive to changes in slide format, but this will make them utilize the full page for the presentation.
I'm using setInterval and not onResize because onResize just don't work on mobile and some browser/os combination (i.e. chrome on windows 8.1 when using keyboard shortcut and desktop hotspots to resize the window)
Related
I have a component that's laid out using polymer-grid-layout which contains a canvas as the main part of the content. I want the canvas to auto resize based on the size that polymer-grid-layout allocates.
I can't put width:100%; height:100% on the canvas as that just stretches the canvas making it distorted and grainy. Instead I wrapped a div around the canvas and manually resize the canvas based on the div size in code.
Code looks somewhat like (note I've left out the boiler plate like etc)
<polymer-grid-layout xnodes="{{xnodes}}"
layout="[[1, 2, 3],
[4, 4, 4]]">
</polymer-grid-layout>
<gauge-slider id='front' label='Front'></gauge-slider>
<panel flex></panel>
<gauge-slider id='back' label='Back'></gauge-slider>
<canvas-view id="canvasView" canvasModel="{{canvasModel}}" flex></canvas-view>
where canvas-view contains
<panel id="canvasContainer" flex>
<canvas id="canvas"></canvas>
</panel>
In the canvas-view dart code I set the canvas width like so
void _resize() {
canvas.width = canvasContainer.clientWidth;
canvas.height = canvasContainer.clientHeight;
_redraw();
}
which I call from
#override
void ready() {
canvas = $['canvas'];
canvasContainer = $['canvasContainer'];
// doesn't seem to be a resize on anything other than window!?!
window.onResize.listen((_) => _resize());
}
and from
#published void set canvasModel(CanvasModel m) {
_canvasModel = m;
// TODO: need to build in a delay as otherwise the containing div has not been sized properly yet
new Timer(new Duration(milliseconds: 50), _resize);
}
The problem is in the above code. If I call _resize directly here then the container div doesn't yet know it's proper height. After experimenting I found that 50 millisecs allows the container to be sized correctly by the grid layout on my machine but that seems really dodgy and likely to be problematic on different devices.
How can I avoid that delay? Is there some event I can listen to that tells me when the grid layout has finished sizing components?
Also was there a simpler way to have achieved the canvas resizing in the first place?
Lastly, I had to style the canvasContainer panel to have 0 margins, border etc. Is there a way to have fetched the inner dimensions of that container?
Is there some event I can listen to that tells me when the grid layout has finished sizing components?
The grid layout sends a polymer-grid-layout event after it has finished sizing components.
Also was there a simpler way to have achieved the canvas resizing in the first place?
I don't think so, but maybe a Canvas expert out there will chime in with better advice.
Lastly, I had to style the canvasContainer panel to have 0 margins, border etc. Is there a way to have fetched the inner dimensions of that container?
clientWidth/Height ignores the margins and border, but does count padding. There are other ways of measuring boxes, but it gets complicated quickly (mostly because of x-browser concerns). This can be a difficult topic, here is a starter link: https://developer.mozilla.org/en-US/docs/Determining_the_dimensions_of_elements
I ran in to this problem on a recent project when the guys in the art department noticed deteriorating image quality. I'm not sure what's causing it however we were able to remedy the issue by removing the ScrollView it was nested in. But this is not a viable solution as we will need to nest images within views nested within scrollviews.
My code looked something like:
<View>
<ScrollView>
<View>
<ImageView image="someImage.png" />
</View>
</ScrollView>
</View>
When we removed the ImageView from both the nested ScrollView and it's direct parent view it renders fine. I've created a repo with a simple project illustrating this. The dulling effect is most noticeable on the coloring of the letters, the white drop shadow on the text and the blurring of the grey border.
https://bitbucket.org/bwellons/blurry-images
Is this a bug that needs reporting or is there documentation somewhere that says "don't do it this way" that I don't know of?
Regards
Brant
I think this is caused by not defining bounds (width, height) and anchors (top, left, right, bottom) of views in a consistent manner, for example, if I just change this:
".parent": {
width: '100%',
height : 59,
}
To this:
".parent": {
top : 0,
width: '100%',
height : 59
}
The blurring goes away. I think this is happening because you are mixing relative and absolute view layout techniques (percentages and absolute pixels) in a tightly bound box (the .parent view is the exact same height as the child image view) which is causing the layout calculations underneath to fudge a little when they draw the image inside the parent view.
I say this because this also works to noticeably eliminate the blur, by allowing more room for transformation error:
".parent": {
width: '100%',
height : 62 // Added 3 pixels of padding
}
Here are some other methods that work as well, by either using the same layout mechanism for both width and height, or giving more room for transforms:
".parent": {
width: '100%',
height : '50%' // Dont do this, but shows the point
}
".parent": {
bottom : 0,
width: Ti.UI.FILL, // I use Ti.UI.FILL instead of 100% generally
height : 59
}
So generally, stay away from mixing percentages and absolute values in nesting view chains dimensions, unless you are willing to give some wiggle room in the parent, or define anchors (top, left, right, bottom) to make the drawing transformations work out.
Disclaimer: I only base this statement on about 15-20 different limited layout tests and my own experience (I did not go through native code, yet) so this is by no means science.
I have a bar graph (note: the length of a bar spans horizontally. conversely, a column graph spans vertically. See below.) My series data can either become a long list or a short list so the number of bars varies between many and few. If I have many bars, my graph needs more height to maintain the same space between bars and maintain the width of the bars. How can I set the height of the graph to ensure that these are fixed?
I looked into a scrollbar for the vertical axis, but I didn't like this because the browser may have it's own vertical scrollbar. I also found advice on dynamically resizing the graph to fit the window, but this is won't work if I have more bars than would fit within a maximized window. So I think the best idea would be to have a graph that sizes with the number of bars. If the bar graph is greater than the page height, the browser's vertical scrollbar will come into action.
Bar graph:
===
==========
=============== ]---- width of bars needs to be maintained.
[spacing between bars also needs to be maintained.]
=======
===========
=== <--- a new bar would simply go here, and chart would increase height by 1 bar width.
The best solution that I have found for this is to determine the size by a simple count of the categories I will need on the server side.
When loading the page, I start with the height needed for the chart's top and bottom margin.
I do a count of my data, and multiply by however much space I need (usually 20, 25 pixels per category, in my cases).
Then set the height of the container accordingly.
I usually do this with php on page load. I'm sure a javascript implementation wouldn't be difficult to achieve.
am using jquerymobile for representing a two column radiobuttons in my project, the problem am facing is the contents of the block-a is lengther than the contents of the block-b so am getting a difference of div size the output is at (http://i40.tinypic.com/r0tt85.png) if u can lookat my out put the second question 6th option is small when compare to all the other ones the block size is based on the content how can i make same size for all the blocks without based on the content any help please needed
If you want all blocks to be the same height, you can set the height in CSS:
.ui-bar {
height: 100px !important;
}
I have a Delphi form with TImages on it. Actually, it's a "fake" desktop with "icons" (the TImages).
When the user resizes the form (scales it or maximizes it, for example) the icons on the form should align proportionally.
Right now, I'm doing something like this with the images:
ImageX.Left:=Round(ImageX.Left * (Width / OldWidth));
ImageX.Top:=Round(ImageX.Top * (Height / OldHeight));
Now this is OK, as long as I start to make the maximized form smaller.
In that case the rightmost images are cut in part by the form's border (they're off the form's client area).
If I reposition these images to fit the client area, then the position of the icons get distorted upon scaling back to maximum size.
Any ideas for a better algorithm/fix?
Thanks!
First of all, you can't have a correctly scaled desktop when you only move the images, and don't scale them as well. You can do slightly better by moving the midpoints of your images, not their top left corner. It still won't be perfect, but it will work better. Of course, now the images will be cropped on all four sides, not just bottom and right, but at least it will be symmetrical :-)
Second, you will get accumulative rounding errors since you constantly override the "original" values (ImageX's top and left coordinate). You'd be better off having the original values stored in some sort of collection or array, and setting the new position based on the original value, rather than the previous value.
Something like this:
ImageX.Left:=Round(ImageX_OriginalLeft * (Width / Original_Width));