-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add box-shadow rendering #1086
Add box-shadow rendering #1086
Conversation
c74b2fe
to
32b8d1c
Compare
@eKoopmans @balupton @gatapia @CyberShadow @andyedinborough Have any solution for it. I have same issue please help me ASAP. |
@AvanishKumar008: Don't be a jerk. Mass-noticing people and begging for help is extremely rude. Not to mention that my only relation to this project is a contribution I made in 2012 (yes, over 5 years ago). |
@CyberShadow I am just asking. I am not forcing you. If you want to fix you can. |
Hi @AvanishKumar008, this is a pull request which means I have solved the problem and I'm asking to add the feature into the repository. It won't be added in until the repo owner approves it. If you want to use |
@eKoopmans You did great job for box shadow and some other thing as well but full picture not showing. Please check again and fix it. Best of luck |
@AvanishKumar008 I'm happy to take a look if you give me a link to an example, but as it is your comment isn't helpful - in all my tests, box-shadows are now rendering correctly. If your comment is about rendering of off-screen elements, please comment over there in the appropriate pull request - and again, it's only helpful if you can give me an example of what's not working. |
hi to everyone..thanks to eKoopmans that built "this custom build"..but i have a problem with |
Any update for this PR ? |
932773c
to
1584357
Compare
Not yet merged. @niklasvh, I believe most of the logic should still stand up, but I'm not sure about the particulars of how you've changed clip, renderBorder, etc. Basically the functions I added (mask, renderShadows, and shadow) mirrored the behaviour of the existing clip, renderBorders, and rectangle/circle/etc. |
Shouldn't be too hard to integrate this with the rewrite, but I'd rather focus on getting bugfixes done and 1.0.0 out asap before adding any new features. |
Not rendering when parent of target element is positioned off screen to avoid using {display:none}. Canvas appears blank. I think integrating this fix to the current release will do since it works well there. I think this was fixed because of introduction of iframe in the current release where the target element is cloned into an iframe even of the parent is hidden. Or what do you think |
Any update on this being merged? |
Will this be merged anytime soon? Is there a fork out there with shadow support? |
When is it going to be merged? Box-shadows are highly used in my project and it would be amazing if it worked someday... @niklasvh |
emmmm,when will this feature merged?it is a very practical feature!!! |
+1 to merging this one 🙏 |
+1 to merging this one too 🙏 |
+1 to merging this one |
var drawShadow = function(shadow) { | ||
var info = parseShadow(shadow); | ||
if (!info.inset) { | ||
context.shadowOffsetX = info.x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context.shadowOffsetX = info.x; | |
if (info.spread > 0) { | |
for (var i = -1; i < 2; i += 2) { | |
for (var i2 = 1; i2 > -2; i2 -= 2) { | |
context.shadowOffsetX = info.x + i * info.spread; | |
context.shadowOffsetY = info.y + i2 * info.spread; | |
context.shadowColor = info.color; | |
context.shadowBlur = info.blur; | |
context.fill(); | |
} | |
} | |
return; | |
} | |
context.shadowOffsetX = info.x; |
When the spread is greater 0 you can draw the shape 4 times to simulate the spread. As long as the spread value is not bigger than double of the actual width / height it should work as intended (or better than not handling it at all).
But it is not possible to do negative spread with this method.
Edit: Additionally it might be good to use shadows.reverse().forEach(drawShadow, this);
instead of shadows.forEach(drawShadow, this);
on line 72, because the browser (or at least Chrome) draws the box-shadow in the opposite order.
Edit2: I forgot to think about opacity (because in my project I had no opacity / blur) so you can probably scratch all of that because it would only work with info.blur=0 and a color without an alpha value
@niklasvh Would you be willing to merge this if I'd integrated it with v1.0.0 and your latest PR ("Typescript conversion")? |
Any update on this being merged? |
@Charlie85270 PR #1848 was merged. It works to some degree. |
its still not working for me |
|
Feature: Box-shadows
You know 'em, you love 'em:
box-shadow
s! Requests for this feature date back to May 2013.Implementation
In
paintElement
, after rendering backgrounds but before borders, there is nowrenderShadows
. It uses a new.mask()
tool which behaves the opposite of.clip()
, meaning the shadow will be drawn only outside the element container.This feature includes support of multiple
box-shadow
s.Related issues/pull requests
#220, #221, #246, #510, #597, #673, #763