Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9063073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:53:54+00:00 2026-06-16T15:53:54+00:00

Hello everyone, var stage = new Kinetic.Stage({ container: ‘container’, width: 1230, height: 40 });

  • 0

Hello everyone,

    var stage = new Kinetic.Stage({
    container: 'container',
    width: 1230,
    height: 40
    });

    var layer = new Kinetic.Layer();
    var rectHeight = 30;
    var rectWidth = 100;
    var rectY = (stage.getHeight() - rectHeight) / 2;

    var triangle = new Kinetic.RegularPolygon({
        x: 25,
        y: 25,
        sides: 3,
        radius: 20,
        fill: '#00D2FF',
        stroke: 'black',
        strokeWidth: 2,
        draggable: true,
        dragBoundFunc: function(pos) {
            return {
                x: pos.x,
                y: this.getAbsolutePosition().y
            }
        }
    });

    // add cursor styling
    triangle.on('mouseover', function() {
        document.body.style.cursor = 'pointer';
    });
    triangle.on('mouseout', function() {
        document.body.style.cursor = 'default';
    });

    triangle.on('dblclick', function(){
        //alert("down");
        layer.clear();
        stage.clear();
    });

    layer.add(triangle);
    stage.add(layer);
}

This is a snippet of my code. This will create a triangle that is able to drag (got it from http://kineticjs.com/ tutorial).

Purpose: I want it to delete the triangle when i double clicked it.

Problem:

i. The triangle can be deleted but when you redraw the triangle, i will draw below the current location where it is deleted. Same thing happen when it is removed and redraw again and again. It will end up at the bottom of my screen after few times of redrawing.

ii. Alert() is used to pop up a notice right? When i use alert(), the triangle can be removed from the screen. If not, it stays there.

Is there anyway to remove the object by mouse event and when another mouse event happen, it will draw the object at the same location?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:53:55+00:00Added an answer on June 16, 2026 at 3:53 pm

    Wish people would supply a working JSFiddle of their problem, its a pain to have to do it myself and your much more likely to get a response if you do.

    Instead of removing the triangle if you want it to reappear in the same spot, why not just hide it?

    var stage = new Kinetic.Stage({
        container: 'container',
        width: 1230,
        height: 40
    });
    
    background = new Kinetic.Layer();
    background.add(new Kinetic.Rect({
        x: 0,
        y: 0,
        width: stage.getWidth(),
        height: stage.getHeight(),
        name: 'backLayer'
    }));
    
    // this rect will allow us to use mouse events on the stage. There's probably a better way to do this, but I don't know it.
    stage.add(background);
    
    var layer = new Kinetic.Layer();
    var rectHeight = 30;
    var rectWidth = 100;
    var rectY = (stage.getHeight() - rectHeight) / 2;
    
    var triangle = new Kinetic.RegularPolygon({
        x: 25,
        y: 25,
        sides: 3,
        radius: 20,
        fill: '#00D2FF',
        stroke: 'black',
        strokeWidth: 2,
        draggable: true,
        dragBoundFunc: function(pos) {
            return {
                x: pos.x,
                y: 25
            }
        }
    });
    
    // add cursor styling
    triangle.on('mouseover', function() {
        document.body.style.cursor = 'pointer';
    });
    
    triangle.on('mouseout', function() {
        document.body.style.cursor = 'default';
    });
    
    triangle.on('dblclick', function(evt) {
        this.hide();
        layer.draw();
        evt.cancelBubble = true;
    });
    
    background.on('click', function() {
        triangle.show();
        layer.draw();
    });
    
    layer.add(triangle);
    stage.add(layer);​
    

    http://jsfiddle.net/RELQp/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello Everyone I am new being in ANDROID so I am getting one problem
hello everyone I am trying to make a script that steps through a list
Hello everyone, I am making a VC++ 2008 project in pure Win32 API which
Hello everyone i am working on a project which requires me to export some
Hello everyone i am try to create backup in postgres through dump. when i
Hello everyone don't know why this code works on windows but not on linux
Hello everyone, I have some confusion regarding some Win32 API data types and macros
Hello everyone I am getting this exception: The magic number in GZip header is
Hello everyone I have a problem. I want to do a GridView with a
Hello everyone I am trying to resize an image of 700kb with imagecreatefromjpeg. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.