I have a list of s checkboxes, and I would like to have a tiny image after each line of lebal text. Unfortunately default Flex fonts look a bit different on different OS and browser combinations, so I cannot place it there manually, but I need to attach it programmatically.
Here is how my checkboxes look like. I use Flex 4.6, how is it possible to do so ?
<s:CheckBox x="10" y="60" label="label1" id="1CB" click="modify();"/>
<s:CheckBox x="10" y="75" label="label2" id="2CB" click="modify();"/>
You can very well try this, the resolution will not change for differnent OS once the width and height of the images are set. Similarly an Image can be added through actionscript also.
<s:HGroup>
<s:CheckBox x="10" y="60" label="label1" id="CB"/>
<mx:Image source="#Embed('untitled.png')" width="50" height="50"/>
</s:HGroup>
<s:HGroup>
<s:CheckBox x="10" y="75" label="label2" id="CB2"/>
<mx:Image source="#Embed('untitled.png')" width="50" height="50"/>
</s:HGroup>
You can use embed fonts for this, they will be show equal in all OS. For examle, write in style file:
#font-face
{
fontFamily: HelveticaNeueLTStd;
src: url("assets/font/HelveticaNeueLTStd-Lt.otf");
embedAsCFF: true;
advancedAntiAliasing: true;
}
global
{
font-family: HelveticaNeueLTStd;
fontSize: 16;
}
Related
I am aware this is a pretty newbie question but I can't figure out a solution on my own.
I have the following SVG hamburger-menu icon:
<svg class="svg-menu" style="margin-top: 1.8rem;margin-right:0.5rem" viewBox="0 0 100 80" width="40" height="18" onclick='fill:red'>>
<rect id="r1" width="100" height="8"></rect>
<rect id="r2" y="30" width="100" height="8"></rect>
<rect id="r3" y="60" width="100" height="8"></rect>
</svg>
At the moment, I can change its color when I click on it by running the following function:
enter code here
$(function(){
$(".svg-menu").on("click",function(){
$("#r1,#r2,#r3").attr("fill","#C8C8C8");
});
});
enter code here
I am unable to figure out how to revert the original color back after clicking on it again (to be clear: on the first click, it changes its color and the menu appears, on the second click the menu disappears but the color remains the same).
Any lead would be greatly appreciated!
Thanks
Well, there was a similar question on StackOverflow in the past. I did a small edit on it, it seems working this way:
let clickNumbers = 0;
$(function(){
$(".svg-menu").on("click",function(){
clickNumbers++;
if(clickNumbers % 2 == 1){
$("#r1,#r2,#r3").attr("fill","#C8C8C8");
} else {
$("#r1,#r2,#r3").attr("fill","#000");
}
});
});
So I have a client logo and I want to animate it on scroll. Let's say that the logo is DANIEL. As the user scrolls down the page i want the spacing between the letters to expand so it would end up being D A N I E L.
I have seen how to do this with regular text but this will be as I said an SVG logo. I have been searching around buy didn't find anything. Also needs to be mobile friendly. Any tips out there?
This is actually very simple. You just need to watch for scroll events, then update the <text> element based on how far down the page you have scrolled.
I've achieved the letter spacing using the letter-spacing presentation attribute.
window.addEventListener("scroll", function() {
document.getElementById("mytext").setAttribute("letter-spacing", (window.scrollY / window.outerHeight) + "em");
});
body {
height: 2000px;
}
svg {
position: fixed;
}
<svg viewBox="0 0 600 100">
<text id="mytext" x="300" y="70" font-size="50" text-anchor="middle">DANIEL</text>
</svg>
Update
For other non-text elements, like <path> etc, you will need to take a slightly different approah. You'll need to physically move them with a transform.
Here is a quick demo. You'll need to tweak it to get the objects to move where you want them.
var EXPAND_AMOUNT = 40;
window.addEventListener("scroll", function() {
var scrollPercent = window.scrollY / window.outerHeight;
document.getElementById("obj1").setAttribute("transform", "translate("+(scrollPercent * 3 * -EXPAND_AMOUNT)+",0)");
document.getElementById("obj2").setAttribute("transform", "translate("+(scrollPercent * 2 * -EXPAND_AMOUNT)+",0)");
document.getElementById("obj3").setAttribute("transform", "translate("+(scrollPercent * -EXPAND_AMOUNT)+",0)");
document.getElementById("obj4").setAttribute("transform", "translate("+(scrollPercent * EXPAND_AMOUNT)+",0)");
document.getElementById("obj5").setAttribute("transform", "translate("+(scrollPercent * 2 * EXPAND_AMOUNT)+",0)");
document.getElementById("obj6").setAttribute("transform", "translate("+(scrollPercent * 3 * EXPAND_AMOUNT)+",0)");
});
body {
height: 2000px;
}
svg {
position: fixed;
}
<svg viewBox="0 0 600 100">
<rect id="obj1" x="165" y="25" width="40" height="50"/>
<rect id="obj2" x="210" y="25" width="40" height="50"/>
<rect id="obj3" x="255" y="25" width="40" height="50"/>
<rect id="obj4" x="300" y="25" width="40" height="50"/>
<rect id="obj5" x="345" y="25" width="40" height="50"/>
<rect id="obj6" x="390" y="25" width="40" height="50"/>
</svg>
http://continent-news.info/page_20.html
In the left column of news, they opens in a popup window, and loaded with Ajax.
<div class="ukraine_mask1">
<svg height="116px" width="142px">
<defs>
<mask id="ukraine_mask1" maskContentUnits="userSpaceOnUse" maskUnits="userSpaceOnUse">
<image xlink:href="mask/ukraine_mask1.png" height="116px" width="142px">
</mask>
</defs>
<foreignObject class="recov_ukraine_mask1" style="mask: url(#ukraine_mask1);" height="100%" width="100%">
<div class="element_mask mask1_ukraine">
<img src="../inf_images/small/7812_8926.jpeg">
</div>
</foreignObject>
</svg>
</div>
problem in Mozilla:
Some news used map with a mask, the first time the mask works well. But if I click another news with mask, they does not want to re-use mask... =( If I press again the first news, it will work.
The second time, does not want to re-use =(
If in firebug disable / apply
mask: url ("# ukraine_mask1")
in
foreignObject class = "recov_ukraine_mask1"
it will work again ...
Maybe someone have an idea how to solve this problem?
I tried to add a simple style in СSS, but does not help = (
In my app I import a twitter timeline. Some tweets contain images, some don't. Also the height of the imqages is variabel. I have a set width of 90% to make sure the images fit in the group (with a vertical layout), but no matter what I do, the group gets it's height from the original image, not the scaled height. I tried setting variableRowHeight="true", but that doesn't seem to do anything.Here is some sample code:
<s:List id="list" y="0" width="90%" height="954" dataProvider="{tweets}" horizontalCenter="0">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer>
<s:Group width="100%">
<s:Label id="twitlabel" text="{tweetImage.height}"
width="100%"
styleName="tweetlist"/>
<s:Image id="tweetImage" y="{twitlabel.height}" width="90%" horizontalCenter="0" scaleMode="letterbox" smooth="true" source="{data.entities.media[0].media_url}"/>
</s:Group>
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
The question is, how can I get the group to set it's height to the scaled image height?
First set the "complete" event handler for your Image and an id for your Group:
<s:Group id="tweetImageGroup" width="100%">
<s:Image id="tweetImage" y="{twitlabel.height}" horizontalCenter="0" scaleMode="letterbox" smooth="true" source="{data.entities.media[0].media_url}" complete="tweetImage_completeHandler(event)"/>
Then set the width after the image has completed loading:
protected function tweetImage_completeHandler(event:Event):void{
tweetImageGroup.height = event.currentTarget.measuredHeight;
}
This might need some adjusting but should work if I understood your problem correctly.
It's a known bug that -moz-border-radius doesnt work on images in firefox. What's a way to get this functionality without resorting to putting the image as a background on a rounded div?
In current Firefox you can use SVG filters. Have an SVG file clip.svg like this:
<svg:svg height="0">
<svg:clipPath id="c1" clipPathUnits="objectBoundingBox">
<svg:rect x="0" y="0" rx="0.05" ry="0.05" width="1" height="1"/>
</svg:clipPath>
</svg:svg>
And apply it in CSS like this:
.target { clip-path: url(clip.svg#c1); }