Ionic Thumbnail crop - ionic-framework

The original image is not quadratic. Currently my thumbnails are distorted. How can I create a cropped thumbnail? CSS Styles seems to have no effect.
<ion-thumbnail item-start style ="object-fit: cover;">
<img src={{item.img}}>
</ion-thumbnail>

You must use the object fit at the img element.
<ion-thumbnail item-start>
<img class="fit-thumbnail" src="{{video.thumbnail}}" alt="">
</ion-thumbnail>
.fit-thumbnail { object-fit: cover; }

Related

ionic 1 - add custom icon to nav button

i'd like to add an image as an icon to a navigation button in the header. is this possible? how should i go about it? here is my current code.. it doesnt work:
in the html code:
<ion-nav-bar class="bar-positive custom-dark">
<ion-nav-buttons side="left">
<button class="button" style="background: #1e1e1c;" ng-click="doSomething()">
<i class="icon home"></i>
</button>
in the css code:
.home
{
background: #1e1e1c;
background-repeat: no-repeat;
background-position: left top;
background-size: contain;
background-image: url('img/finalimages/home.png');
display: inline;
}
You could create a custom icon which can be put as your default back button alternative in ionic.
By doing this way you are getting a number of custom icons which can be used throughout your project.
This can be made by following this tutorial:here

Move parallax per slide progress instead of total progress

I'm writing an Ionic 2 app and want to use the Slider component (based on Swiper) to do something similar to this demo: http://idangero.us/swiper/demos/28-parallax.html
But whenever I add a parallax item it moves based on the total slider progress (like the background in the demo) and I found no way to have them move based on a single slide progress (like the text in the demo). (Swiper docs)
Does anyone know if that's possible? The Ionic docs don't have any details on parallax in slides.
What I tried:
<ion-slides parallax progress>
<ion-slide>
<h2>No Parallax</h2>
<p data-swiper-parallax="-100">Parallax: -100</p>
<p data-swiper-parallax="-200">Parallax: -200</p>
</ion-slide>
<ion-slide>
<h2>No Parallax</h2>
<p data-swiper-parallax="-100">Parallax: -100</p>
<p data-swiper-parallax="-200">Parallax: -200</p>
</ion-slide>
<ion-slide>
<h2>No Parallax</h2>
<p data-swiper-parallax="-100">Parallax: -100</p>
<p data-swiper-parallax="-200">Parallax: -200</p>
</ion-slide>
</ion-slides>
Demo: http://plnkr.co/edit/k0b92hqkdeUR57t71RR4?p=preview
You can achieve this by putting your background image to be parallaxed in the first slide, like this:
<ion-slides parallax pager>
<ion-slide>
<div class="image-parallax">
<img data-swiper-parallax="2100" src="url.to/image.png"/>
</div>
</ion-slide>
<ion-slide>
<p> Other slide content </p>
<ion-slide>
</ion-slides>
And then, style the div as this:
.image-parallax{
position: absolute;
img{
margin-left: 200px;
width: 2000px;
height: auto;
}
}
And then adjust the margins, width and height of the background.
Hope it helps!
I have managed to solve this with ionic 4, putting the background image in and making the background-attachment local.
my.page.html:
<ion-slides [options]="slideOpts" class="parallax-bg" data-swiper-parallax-x="-20%" [ngStyle]="{'background-image':'url(assets/images/background_'+category+'.svg)'}">
my.page.scss:
.parallax-bg {
background-position: center;
background-attachment: local;
background-repeat: repeat-x;
}

Featherlight.js plugin: lightbox's width issue when content is an iframe

Using Featherlight jQuery plugin and setting text as the content of my lightbox, my lightbox's width is about 80% of the screen: http://goo.gl/4BVzHM. But if I replace the text by a YouTube iframe, the lightbox's width is reduced to 500px or so, cropping the video.
Code:
<a id='open_lightbox' data-featherlight='.lightbox_content' href='#'>open lightbox</a>
<div class='lightbox_content'>
<iframe width="1280" height="720" src="https://www.youtube.com/embed/g7fbe-oV-X0?rel=0" frameborder="0" allowfullscreen></iframe>
</div>
I tried to use the jQuery binding method too:
$( '#open_lightbox' ).featherlight(
{
iframe: 'https://www.youtube.com/embed/g7fbe-oV-X0?rel=0',
iframeWidth: 1200,
iframeHeight: 800
}
);
Same problem.
(also there are thin white horizontal bands above and below the video, I don't understand why)
To remove the background white color
add background: none; to featherlight-content div
To change the width use '!important`
style="width: 600px !important;

YUI pure css fixed width

Can someone show me an example of how I might use purecss.io to implement a fixed width/responsive design, similar to the 960 grid like bootstrap, etc???
The fluid width simply won't work for my particular design, here is what I currently have:
<nav class="pure-u" id="menu">
<div class="pure-menu pure-menu-open">
<a class="pure-menu-heading" href="/">HOME</a>
<ul>
<li class="pure-menu-selected">Clients</li>
<li>Company</li>
<li>Portfolio</li>
<li>Service</li>
<li>Contact</li>
</ul>
</div>
</nav>
<div class="pure-u-1" id="main">
This is the main content area
</div>
</div>
</body>
I need the above wrapped in a containing DIV which centers and has a fixed width of 960 but adjusts responsively as required...
Any ideas???
Regards,
Alex
hope this helps: http://jsfiddle.net/pX7bD/.
The idea is to wrap everything in a div that has a fixed max-width and auto horizontal margins (so it's centered).
#wrapper {
max-width: 960px;
margin: 0 auto;
}

image map not working on iOS devices, with large images that get rescaled by the device

I'm developing an internal web app on our company intranet using PHP. One section of the app displays a couple of high resolution images to the user. These images are in the region of 5000x3500 pixels. Each image has an image map (using rectangular areas), and all works fine in the desktop browsers I've tried.
The problem I'm finding, is that when users access the site via their iOS devices, the images are being rescaled by safari on the device, however the image map coordinates are not being adjusted to match.
An example of the HTML being generated by my PHP is as follows:
<img src="largeimage.jpg" width="5000" height="3500" usemap="#examplemap">
<map name="examplemap">
<area shape="rect" coords="0,0,5000,500" href="blah1"/>
<area shape="rect" coords="0,500,2500,3500" href="blah2"/>
<area shape="rect" coords="2500,500,5000,3500" href="blah3"/>
</map>
(The actual rectangle coordinates in the image map are calculated as a percentage of the image size).
I know that safari is resizing the image due to memory constraints on the device, but I need to either find a way of scaling the image map to suit, or replacing the image map with something else that will do the same job. Can anyone offer any advise?
This topic was solved here on stackoverflow: jquery-image-map-alternative
The best idea is to use absolutely positioned anchors (also as suggested by steveax) instead of imagemap.
Update
As this is an old question, you might consider using SVG maps these days. They are supported in all modern browsers, works responsively and are as easy to use as image maps. (thanks to user vladkras for reminder)
Why don't you use Responsive Image Maps instead. This way you can still use poly maps for oddly shaped items.
http://mattstow.com/experiment/responsive-image-maps/rwd-image-maps.html
It's as easy as adding the script. And one line of javascript:
$('img[usemap]').rwdImageMaps();
Nathan's comment is correct. You need to fix the viewport to prevent scaling. Basically, either specify a fixed pixel width, or set the scale to 1.0 and set user-scalable=no
See this document for reference:
http://developer.apple.com/library/ios/#DOCUMENTATION/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html
An alternative to using the area tag is to use javascript with events x/y & bounds for your hit areas.
I ran into this limitation recently on a project where we needed to be able to zoom and this is what I did to solve it:
Split the image up into 4 quadrants
Placed the 4 images into divs with width and height set to 50% and position: absolute;
Absolutely positioned <a> elements within the quadrant's parent element using
percentage values and a high z-index
Like this:
CSS
#map-frame { position: relative; }
.map {
display: block;
position: absolute;
width: 5%;
height: 3%;
z-index: 99;
}
.q {
position: absolute;
width: 50%;
height: 50%;
}
.q img {
display: block;
max-width: 100%;
}
.q1 {
top: 0;
left: 0;
}
.q2 {
top: 0;
right: 0;
}
.q3 {
bottom: 0;
left: 0;
}
.q4 {
bottom: 0;
right: 0;
}
HTML
<div id="map-frame">
<a class="map" href="foo.html" style="top: 20%; left: 20%;">
<a class="map" href="foo.html" style="top: 40%; left: 20%;">
<a class="map" href="foo.html" style="top: 20%; left: 40%;">
<a class="map" href="foo.html" style="top: 40%; left: 40%;">
<div id="q1" class="q">
<img alt="" src="q1.jpg" />
</div>
<div id="q2" class="q">
<img alt="" src="q2.jpg" />
</div>
<div id="q3" class="q">
<img alt="" src="q3.jpg" />
</div>
<div id="q4" class="q">
<img alt="" src="q4.jpg" />
</div>
</div>
Put all the content INSIDE A TABLE. Set to 100% width. The iphone doesnt seem to scale tables... I was struggling with this problem as i had my images just lose, or inside a div.
none of the rect coords links were working. But when i put the whole lot inside a table... Well, just try it and see :)
I dig out this post because I've just found a solution to get image map working on iOS.
Put your map within an anchor and listen click/tap events on it, to check if the target element matches with a map's area.
HTML
<a id="areas" href="#">
<img src="example.jpg" usemap="#mymap" width="1024" height="768">
<map name="mymap">
<area id="area1" shape="poly" coords="X1,Y1,X2,Y2...">
<area id="area2" shape="poly" coords="X1,Y1,X2,Y2...">
<area id="area3" shape="poly" coords="X1,Y1,X2,Y2...">
</map>
</a>
JAVASCRIPT
$("#areas").on("click tap", function (evt) {
evt.preventDefault();
if (evt.target.tagName.toLowerCase() == "area") {
console.log("Shape " + evt.target.id.replace("area", "") + " clicked!");
}
});
Tested on iPad4 with mobile safari 6.0
Do not use Default <img usemap="#map"> and <map name="map"> change it. Like <img usemap="#mapLink"> and <map name="mapLink">. It's working !!!
Simply using a # in the usemap attribute appears to solve the problem on iPhone.
For example <img usemap="#mapLink"> and <map name="mapLink">
My solution was easy. I just assigned a height and width in the DIV's css to match the size of the image and everything worked fine. Original image size was 825 x 1068, so
<div style= width: 825px; height: 1068px;">
...
</div>
Hope it helps.
I solved this with only 1 line of code, no JavaScript. Only CSS, you need to use zoom property to scale your image and everything will work fine, just like this
img {
zoom: 0.3;
}
<img src="largeimage.jpg" width="5000" height="3500" usemap="#examplemap">
<map name="examplemap">
<area shape="rect" coords="0,0,100%,10%" href="blah1"/>
<area shape="rect" coords="0,10%,50%,70%" href="blah2"/>
<area shape="rect" coords="50%,10%,100%,70%" href="blah3"/>
</map>
please try using percentage values inside coordinates